CI在nginx環境下去掉url中的index.php


在nginx環境下CI框架默認URL規則訪問不了,出現500錯誤,如:

http://blog.php230.com/index.php/keywords

今天在服務器配置CI框架環境時,去除URL中的index.php,出現了默認URL規則訪問不了的情況,只能通過參數方式訪問:

http://blog.php230.com/index.php?c=keywords

配置:

location /{
	if (-f $request_filename) {
		expires max;
		break;
	}
	if (!-e $request_filename) {
		rewrite ^/(.*)$ /index.php/$1 last;
		break;
	}
}

自己在lnmp測試環境下使用正常,在正式服務器上就不能使用。

解決方法:

location /{
	try_files $uri $uri/ /index.php?$uri&$args;
}

把重寫規則改為上面就可以正常訪問了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM