2012-03-24 31 views
1

我在.htaccess有以下內容。文件:如何修復這個mod_rewrite規則中的無限循環?

RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_URI} !^/css(/?|/.+)$ 
RewriteCond %{REQUEST_URI} !^/js(/?|/.+)$ 
RewriteCond %{REQUEST_URI} !^/img(/?|/.+)$ 
RewriteRule !^/handle\.php$ /handle.php [L] 

我只是想所有請求(除了那些/css//js//img/開始)被髮送到handle.php

但是,當我提出要求,我得到一個500錯誤,這是印在錯誤日誌:

[Sat Mar 24 16:14:53 2012] [error] [client x.x.x.x] 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.

爲什麼讓一個無限循環?

回答

1

這可能是重寫一個請求到/handle.php不匹配!^/handle\.php$,所以它會嘗試重寫重寫等。您的問題可能是主導斜線?嘗試玩這個。

如果沒有,請查看RewriteLog指令(並參閱下面的條目,RewriteLogLevel)。您將能夠看到正在嘗試重寫的內容,並且您可能會弄清楚發生了什麼問題。

+0

你是對的。將最後一行更改爲'RewriteRule!^/handle \ .php $ handle.php [L]'並且它可以工作。謝謝。 – callum 2012-03-24 15:44:10