刚刚配置好nginx能运行php的了,没想到拉了一个tp的项目进来运行不起来,各类求助最后找到了解决的方案。php
这段代码是经过好友求助html
rewrite ^(.*)$ /index.php?s=$1 last;
我发现配置好了后访问是成功了,最后url访问是成功可是访问只有一个结果都是同一个页面,最后获得的结果是下面这段代码nginx
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
这段代码配合前面的代码才能够。因为我以前在tp里配置过路由觉得是路由跟nginx冲突有问题结果不是,我经过全路径去访问都是404.url
完整的代码配置是这样的 .net
location / { root xxx/xxx; index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^/index.php(.*)$ /index.php?s=$1 last; #必须在前面 rewrite ^(.*)$ /index.php?s=$1 last; break; } }