2012-02-10 59 views
0

在我.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的託管上失敗。

回答

2
RewriteRule ^(?!index\.php).*$ index.php/$0 [L,QSA] 

您需要防止無限循環。對index.php的否定斷言是阻止這種情況的一種方法。

+1

不知道如果我喜歡消極的斷言,但它節省的RewriteCond。我應該看看那些。 +1讓我意識到他們的存在:-) – Gerben 2012-02-10 22:38:50

0

我實際上在CodeIgniter forum找到了答案。

它並沒有解決我的規則,而是又做了一個稍微不同的方式:

Options -MultiViews 
RewriteEngine on 
RewriteBase /dev 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+) index.php/$1 [L]