Apache 2.4 - 由于可能的配置错误,请求超出了10个内部重定向的限制

时间:2014-03-31 08:25:13

标签: wordpress apache .htaccess rewrite

我在Windows Server 2008 R2 Enterprise上运行Apache 2.4(64位)和PHP 5.4.15,并注意到Apache错误日志中出现以下错误:

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.

我有一个多站点安装的WordPress运行,我认为错误来自htaccess重写中的错误。

看看这篇文章: Request exceeded the limit of 10 internal redirects due to probable configuration error.?

他们建议替换这个:

# BEGIN Wordpress
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
</IfModule>
# END WordPress
这段代码由Scott Yang提供:

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

然而,我的WordPress htaccess看起来有点不同,所以我不想仅仅因为我无意中替换了我需要的东西而替换我的代码。

这是我的htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
Header set Access-Control-Allow-Origin "*"
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress

有人可以建议我需要改变什么吗?

4 个答案:

答案 0 :(得分:23)

此问题可能是由于对某些不存在的文件的请求造成的。例如,请求wp-content / uploads /中文件不存在的文件。

如果您遇到这种情况,可以转到.htaccess并更改此行来解决问题:

RewriteRule ^(wp-(content|admin|includes).*) $1 [L]

为:

RewriteRule ^(wp-(content|admin|includes).*) - [L]

潜在的问题是上面的规则触发了重写到完全相同的url,并且前面有斜杠,并且因为有重写,新重写的请求再次返回规则并触发相同的规则。通过更改该行&#34; $ 1&#34; to&#34; - &#34;,没有重写,因此重写过程不会重新开始使用相同的URL。

apache 2.2和2.4如何处理这种只有差异的情况可能会有所不同,这也就是提供默认规则的原因通过WordPress完美地工作。

答案 1 :(得分:13)

由于这些规则,您很可能会进入循环:

RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]

只需将其评论出来,然后在新浏览器中重试。

答案 2 :(得分:0)

通过添加以下

解决了这个问题
RewriteCond %{ENV:REDIRECT_STATUS} 200 [OR]
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]

答案 3 :(得分:0)

在我们的例子中,编辑器使用相同的 slug 创建了一个自定义帖子类型和一个自定义内容类型。我们通过在 [ WordPress › 工具 › 设置 ] 中删除一个并重新保存永久链接来修复它。

希望对大家有所帮助。