thinkphp 在nginx中的配置问题

今天在虚拟机上部署thinkphp项目,服务器是nginx,用了下面的代码来去掉index.php;

location / {
            if (!-e $request_filename){
            rewrite ^/(.*)$ /index.php?s=$1 last;
                    break;
            }
    }

结果 index.php是去掉了 但是连接中自动加上了模块名称。本来访问地址是 http://www.test.com/home/main/index 但是实际跳转时却变成了http://www.test.com/home/home/main/index 自动加上了一个home。这是为什么呢?

阅读 2.5k
2 个回答
location / { // …..省略部分代码
   if (!-e $request_filename) {
   rewrite  ^(.*)$  /index.php?s=/$1  last;
   break;
    }
 }

少了斜杠/$1 last;试试看

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题