首页 > nginx的index指令有什么作用?

nginx的index指令有什么作用?

server {
        listen 80;
        server_name phpcms.me m.phpcms.me;
        root /mnt/hgfs/www/open/phpcms;
        charset utf-8;
        index index.html index.php;
        try_files $uri $uri/ @rewrite;
        location ~ \.php {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi.conf;
        }
        location @rewrite {
            rewrite ^/(.*)$ /index.php?_url=/$1;
        }
}

这个是我的nginx配置,网站根目录下有一个qiantu目录,里面有静态的内容页,不存在文件index.html。
通过 phpcms.me/qiantu/index.html可以访问列表页首页,是走的@rewrite规则
但是通过 phpcms.me/qiantu/ 就是直接403 forbidden了,根本没走@rewrite规则。
但是删除根目录下的qiantu目录 访问 phpcms.me/qiantu/ 又可以走@rewrite规则进行访问了。
想问下怎样保留根目录下的qiantu目录的同时,通过访问phpcms.me/qiantu/ 可以让其通过location进行匹配而不是直接403 forbidden

这里的qiantu目录只是个例子 ,不是固定的,因此不能通过 location = /qiantu/ {} 进行匹配。


chmod下试试

【热门文章】
【热门文章】