2012-02-10 87 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]