【问题标题】:Error: Request exceeded the limit of 10 internal redirects due to probable configuration error错误:由于可能的配置错误,请求超出了 10 个内部重定向的限制
【发布时间】:2017-09-23 03:36:16
【问题描述】:

这个问题已经被问过几次了,但是在查看了所有相关的帖子之后,我仍然找不到解决方案。 我正在运行 VPS(在 Ubuntu 14.04 上)并使用以下 Apache 指令来阻止垃圾邮件机器人:

RewriteEngine On
RewriteOptions inherit
RewriteCond %{HTTP_USER_AGENT} (Yandex|GozaikBot|EveryoneSocialBot) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} (MJ12bot|Ezooms|Ahrefs|AndersPinkBot) [NC]
RewriteRule ^(.*)$ - [F,L]

当我使用与任何这些机器人名称匹配的用户代理模拟 HTTP 请求时,如预期的那样,我看到“禁止”和“您无权访问此服务器上的 /index.php”,但我也看到“ 此外,在尝试使用 ErrorDocument 处理请求时遇到了 500 Internal Server Error 错误。”,最重要的是,在错误日志中,我看到如下记录: "...AH00124:由于可能的配置错误,请求超出了 10 次内部重定向的限制。如有必要,请使用 'LimitInternalRecursion' 增加限制。使用 'LogLevel debug' 获取回溯。

我的重写规则实际上有超过 60 个被阻止的机器人,我只是在这里缩短了它们以节省空间。我每天都会从这些机器人获得数千次点击,因此我的错误日志中充斥着这些 AH00124 错误...

对我的重写规则有什么问题有任何想法吗?关于如何解决问题的任何建议?

2017 年 4 月 27 日更新:

也许这与我的服务器配置有关?我让 Nging 在 Apache 前面以代理模式运行,上面列出的指令已设置为 Apache 的 HTTP/HTTPS 指令。

这是我在将日志级别提高到“调试”时在日志中看到的内容:

[Thu Apr 27 13:26:38.858812 2017] [core:error] [pid 6671] [client 199.99.99.99:53115] 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.
[Thu Apr 27 13:26:38.861026 2017] [core:debug] [pid 6671] core.c(3518): [client 199.99.99.99:53115] AH00121: r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861052 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861061 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861067 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861073 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861079 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861085 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861091 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861155 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861163 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:38.861169 2017] [core:debug] [pid 6671] core.c(3525): [client 199.99.99.99:53115] AH00122: redirected from r->uri = /fees.php
[Thu Apr 27 13:26:39.257662 2017] [core:error] [pid 6669] [client 199.99.99.99:53116] 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.
[Thu Apr 27 13:26:39.257711 2017] [core:debug] [pid 6669] core.c(3518): [client 199.99.99.99:53116] AH00121: r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257718 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257722 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257726 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257730 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257734 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257737 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257741 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257744 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257748 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /error_docs/banned.html
[Thu Apr 27 13:26:39.257751 2017] [core:debug] [pid 6669] core.c(3525): [client 199.99.99.99:53116] AH00122: redirected from r->uri = /favicon.ico

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    我不确定。但是试试

    RewriteEngine On
    RewriteOptions inherit
    RewriteBase /
    RewriteCond %{HTTP_USER_AGENT} (Yandex|GozaikBot|EveryoneSocialBot) [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} (MJ12bot|Ezooms|Ahrefs|AndersPinkBot) [NC]
    RewriteRule .* - [F,L]
    

    【讨论】:

    • 将最后一行更改为 RewriteRule .* - [F,L] 没有区别。
    • 怎么样:RewriteBase /
    • 添加 RewriteBase 时出现语法错误“RewriteBase:仅在每个目录的配置文件中有效”/
    • 第二行有哪些选项?
    • 我不确定您的问题...我使用 RewriteOptions 继承,因为我希望将其应用于所有文件夹。我假设它与 Apache 指令的行为相同,就好像我使用 .htaccess...
    【解决方案2】:

    感谢 Michael Orlitzky 的 article,我设法解决了这个问题,他建议使用 RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f 作为RewriteBase 的“等价物”(@barbocc 的回答/评论让我想到了 RewriteBase)。虽然 RewriteBase 在 Apache vhosts 设置中不起作用,但“RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f”可以。虽然,我使用的是“!/error_docs/forbidden.html”而不是“!-f”,因为我想阻止机器人访问除此文件之外的所有内容。这是最终代码:

    RewriteEngine On
    RewriteOptions inherit
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !/error_docs/forbidden.html
    RewriteCond %{HTTP_USER_AGENT} (Yandex|GozaikBot|EveryoneSocialBot) [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} (MJ12bot|Ezooms|Ahrefs|AndersPinkBot) [NC]
    RewriteRule ^(.*)$ - [F,L]
    

    【讨论】:

    • 感谢您的研究工作和来源!帮了我很多:-) 只需替换 rewritebase 行就可以了。
    猜你喜欢
    • 2012-05-03
    • 2010-12-09
    • 1970-01-01
    • 2018-08-21
    • 2014-01-26
    相关资源
    最近更新 更多