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