2016-07-26 112 views
1

這是我的.htaccess文件:重定向所有請求到index.php的.htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php [L] 

我收到500內部服務器錯誤。此命令後: 貓/var/log/apache2/error.log 我得到這個錯誤:

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 

請幫我理清這一點?

+0

它存在那裏。 –

+0

然後只是這個規則不能導致重寫循環 – anubhava

+0

什麼版本的apache? – Will

回答

2

將您的htaccess規則更改爲下面,然後它將工作。

RewriteEngine On 
    RewriteBase/
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.+)$ /index.php/$1 [L,QSA] 
0

結帳this serverfault answer

總之,[L]只會停止當前規則集的處理,並將重寫的URL傳遞迴URL解析引擎,該引擎可能會再次應用您的規則集。 10倍。然後Apache說停止。

你可以添加一個條件,如果重寫已經將index.php不重寫:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !=/index.php 
RewriteRule . index.php [L] 

或者,你可以在你的其他規則之前檢查ENV:REDIRECT_STATUS和停止施加任何進一步的規則:

RewriteEngine On 

RewriteCond %{ENV:REDIRECT_STATUS} 200 
RewriteRule^- [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php [L] 
相關問題