yii2 - nginx中location裡的root和server裡的root區別
PHP中文网
PHP中文网 2017-05-16 17:19:37
0
2
619
server
    {
        ...
        #我在server中定义了root
        root  /home/www/zscx;
        ....
        #location中也定义一个root
        location /
        {
           root /home/www/zscx/web;
           try_files $uri /index.php?$args;
        }
        ...
    }
    

訪問地址www.xxx.com/site/test
希望訪問到的目的地址是www.xxx.com/web/index.php?r=site/test
但是實際上訪問到得是www.xxx.com/index.php?r=site/test
也就是我在location設定的root沒有運作啊,如果在最開始設定root /home/www/zscx/web 那就是好的。
求解為什麼?

try_files $uri /index.php?$args;
改為try_files $uri /web/index.php?$args;這樣子確實可以,但是還是會出現/web這個目錄。我想實現的是www.domain.com/controller/function

其實就是為了解決Yii2的pathinfo模式

#
PHP中文网
PHP中文网

认证高级PHP讲师

全部回覆(2)
小葫芦

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

阿神

yii2你想把web隱藏掉,root路徑包含到web就可以了,yii文檔裡我記得有說只有 web目錄是可訪問的。至於你說的那個情況是root有起作用啊,所以才不用寫web路徑

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!