2012-03-24 33 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