yii2 - The difference between root in location and root in server in nginx
PHP中文网
PHP中文网 2017-05-16 17:19:37
0
2
618
server
    {
        ...
        #我在server中定义了root
        root  /home/www/zscx;
        ....
        #location中也定义一个root
        location /
        {
           root /home/www/zscx/web;
           try_files $uri /index.php?$args;
        }
        ...
    }
    

Access address www.xxx.com/site/test
The destination address I hope to access is www.xxx.com/web/index.php?r=site/test
But actually accessed It is www.xxx.com/index.php?r=site/test
That is, the root I set in the location does not work. If I set root /home/www/zscx/web at the beginning That’s good.
Explain why?

Change try_files $uri /index.php?$args;
to try_files $uri /web/index.php?$args;This is indeed possible, But the directory /web will still appear. What I want to achieve is www.domain.com/controller/function

In fact, it is to solve the pathinfo mode of Yii2

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
小葫芦

https://github.com/yiisoft/yii2/blob/master/docs%2Fguide%2Fstart-installation.md#recommended-nginx-configuration-

阿神

yii2 If you want to hide the web, just include the root path into the web. I remember in the yii documentation that only the web directory is accessible. As for the situation you mentioned, root is working, so there is no need to write the web path

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!