【问题标题】:Can't block bots in htaccess无法在 htaccess 中阻止机器人
【发布时间】:2019-07-23 14:36:21
【问题描述】:

我尝试使用以下代码通过 htaccess 阻止坏机器人: 我知道这是 2 种方法,但它们都不起作用,我仍然在访问日志中看到机器人:我做错了什么?

RewriteCond %{HTTP_USER_AGENT} ^BLEXBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^SemrushBot [NC,OR]
SetEnvIfNoCase User-Agent "BLEXBot" rotbot
SetEnvIfNoCase User-Agent "SemrushBot" rotbot

<Limit POST GET HEAD PUT>
        Order Allow,Deny
        Allow from all
        Deny from env=rotbot
</Limit>

访问日志中的条目如下所示:

domain.org:443 46.229.168.142 - - [22/Jul/2019:08:56:26 +0200] "GET /path/to/page/ HTTP/1.1" 403 3801 "-" "Mozilla/5.0 (compatible; SemrushBot/3~bl; +http://www.semrush.com/bot.html)"
domain.org:443 94.130.219.232 - - [22/Jul/2019:08:56:24 +0200] "GET /path/to/page/ HTTP/1.1" 403 760 "-" "Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)"

【问题讨论】:

    标签: .htaccess bots


    【解决方案1】:

    将这些规则修改为:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_USER_AGENT} ^BLEXBot [NC,OR]
        RewriteCond %{HTTP_USER_AGENT} ^SemrushBot [NC]
        RewriteRule ^.* - [F,L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-19
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 2020-02-09
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      相关资源
      最近更新 更多