刚刚配置好nginx能运行php的了,没想到拉了一个tp的项目进来运行不起来,各种求助最后找到了解决的方案。
这段代码是通过好友求助
rewrite ^(.*)$ /index.php?s=$1 last;
我发现配置好了后访问是成功了,最后url访问是成功但是访问只有一个结果都是同一个页面,最后得到的结果是下面这段代码
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
这段代码配合前面的代码才可以。由于我之前在tp里配置过路由以为是路由跟nginx冲突有问题结果不是,我通过全路径去访问都是404.
完整的代码配置是这样的
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;
}
}
参考地址 http://www.jb100.net/html/content-28-519-1.html