最近在一台装了nginx服务器环境下,配置thinkphp,然后pathinfo模式无法使用。查了很多资料,终于处理处理OK了。
1、首先 find / -name nginx.conf
2、找到后 vi nginx.conf
然后 注释掉 php-enable.conf
#include php-enable.conf
include enable-php-pathinfo.conf
3、然后再添加上
//实例如下
location / {
if (!-e $request_filename){
rewrite ^/$ /index.php;
rewrite ^/(.*)$ /index.php?s=$1 last;
}
}
最后保存重启即可。我用的是lnmp一键包, 直接lnmp nginx restart, OK
http://10.61.193.10/tpshen/index.php/home
4、如果想省略index.php (你的项目在二级目录)则
location /youdomain/ {
if (!-e $request_filename){
rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=$1 last;
}
}
然后就可以 http://10.61.193.10/tpshen/home