在我.htaccess
使用以下重寫規則時,我不斷收到500內部服務器錯誤:錯誤500或重寫規則得到乾淨的URL
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
從本質上講,我想在我的web應用乾淨的URL,即www.example.com/login的功能與的功能相同www.example.com/index.php/login。
此重寫規則在本地MAMP和不同的Apache測試服務器上正常工作,但在客戶端基於1and1.com的託管上失敗。
在我.htaccess
使用以下重寫規則時,我不斷收到500內部服務器錯誤:錯誤500或重寫規則得到乾淨的URL
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
從本質上講,我想在我的web應用乾淨的URL,即www.example.com/login的功能與的功能相同www.example.com/index.php/login。
此重寫規則在本地MAMP和不同的Apache測試服務器上正常工作,但在客戶端基於1and1.com的託管上失敗。
RewriteRule ^(?!index\.php).*$ index.php/$0 [L,QSA]
您需要防止無限循環。對index.php
的否定斷言是阻止這種情況的一種方法。
我實際上在CodeIgniter forum找到了答案。
它並沒有解決我的規則,而是又做了一個稍微不同的方式:
Options -MultiViews
RewriteEngine on
RewriteBase /dev
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php/$1 [L]
不知道如果我喜歡消極的斷言,但它節省的RewriteCond。我應該看看那些。 +1讓我意識到他們的存在:-) – Gerben 2012-02-10 22:38:50