nginx的index指令有什么作用?
PHP中文网
PHP中文网 2017-05-16 17:20:27
0
1
387
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=/;
        }
}

这个是我的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/ {} 进行匹配。

PHP中文网
PHP中文网

认证0级讲师

全部回复(1)
为情所困

chmod下试试

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!