问题描述
server {...#我在server中定义了rootroot /home/www/zscx;....#location中也定义一个rootlocation /{ 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模式
问题解答
回答1:https://github.com/yiisoft/yii2/blob/master/docs%2Fguide%2Fstart-installation.md#recommended-nginx-configuration-
回答2:yii2你想把web隐藏掉,root路径包含到web就可以了,yii文档里我记得有说只有 web目录是可访问的。至于你说的那个情况是root有起作用啊,所以才不用写web路径