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

问题描述 投票:16回答:3

我在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

任何人都可以建议我需要改变什么?

wordpress apache .htaccess rewrite
3个回答
13
投票

由于这些规则,您最有可能进入循环:

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

只需将其注释掉,然后在新的浏览器中重试。


23
投票

请求某些不存在的文件可能会导致此问题。例如,对文件不存在的wp-content / uploads /中的文件的请求。

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

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

至:

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

根本问题是上面的规则触发重写到完全相同的url,前面有斜杠,并且因为有重写,新重写的请求再次返回规则并触发相同的规则。通过将该行的“$ 1”更改为“ - ”,不会发生重写,因此重写过程不会使用相同的URL重新开始。

apache 2.2和2.4如何处理这种只有差异是斜线的情况可能存在差异,这就是为什么WordPress提供的默认规则不能完美运行的原因。


0
投票

通过添加以下解决此问题

RewriteCond %{ENV:REDIRECT_STATUS} 200 [OR]
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
© www.soinside.com 2019 - 2024. All rights reserved.