What is the function of nginx's index directive?
PHP中文网
PHP中文网 2017-05-16 17:20:27
0
1
386
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=/;
        }
}

This is my nginx configuration. There is a qiantu directory in the root directory of the website, which contains static content pages and the file index.html does not exist.
You can access the homepage of the list page through phpcms.me/qiantu/index.html, and the @rewrite rule is followed
But through phpcms.me/qiantu/, it is directly 403 forbidden, and the @rewrite rule is not followed at all.
But delete the qiantu directory in the root directory and access phpcms.me/qiantu/, and you can access it through the @rewrite rule.
I would like to ask how to retain the qiantu directory in the root directory while accessing phpcms.me/qiantu/ so that it can be matched by location instead of directly 403 forbidden

The qiantu directory here is just an example and is not fixed, so it cannot be matched by location = /qiantu/ {}.

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
为情所困

Try it under chmod

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!