lnmp配置支持thinkphp和nginx路由url重写


ThinkPHP3.2.3项目放到lnmp环境之后只能打开首页,或者通过传参方式打开控制器,否则就一直显示404页面。搞了一上午,终于解决了

step1:
修改php.ini

cgi.fix_pathinfo=1

step2:

修改nginx.conf或者vhost/*.conf

注释掉include enable-php.conf

添加include enable-php-pathinfo.conf

step3:
加入重写规则

location / {
if (!-e $request_filename) {

rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
index index.html index.htm index.php l.php;
autoindex off;
}

step4:
重启lnmp:

lnmp restart


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM