这个问题已被问过几次,但在审核了所有相关帖子后,我仍然无法找到解决方案。 我正在运行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内部服务器错误错误。“,最重要的是,在错误日志中我看到如下记录: “ ... AH00124:由于可能的配置错误,请求超出了10个内部重定向的限制。如有必要,请使用'LimitInternalRecursion'来增加限制。使用'LogLevel debug'来获取回溯。 “
我的重写规则实际上有超过60个被阻止的机器人,我只是将它们缩短到这里以节省空间。我每天从这些机器人中获得几千次点击,所以我的错误日志充斥着这些AH00124错误...
关于我的重写规则有什么问题的任何想法?有关如何解决问题的任何建议?
在4/27/17更新:
也许它与我的服务器配置有关?我让Nging在Apache前面以代理模式运行,上面列出的指令已被设置为Apache的HTTP / HTTPS指令。
以下是将日志级别增加到“debug”时在日志中看到的内容:
[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
答案 0 :(得分:2)
由于Michael Orlitzky的 article ,我设法解决了这个问题,他提议使用 RewriteCond%{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-f 作为一个等同的" RewriteBase(@barbocc的回答/评论让我想到了RewriteBase)。虽然RewriteBase在Apache vhosts设置中不起作用,但" RewriteCond%{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-f "确实。虽然,而不是"! - f"我正在使用"!/ error_docs / forbidden.html"因为我想阻止机器人访问除此文件以外的所有内容。这是最终的代码:
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]
答案 1 :(得分:0)
我不确定。但是试试
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]