【问题标题】:How can I block a Bot with .htaccess如何使用 .htaccess 阻止 Bot
【发布时间】:2013-12-11 18:24:56
【问题描述】:

我遇到了 bot* 和 *bot 的问题。我对 .htaccess 的了解有限,但一直在使用以下 .htaccess 规则阻止机器人。

我的问题分为两部分:

  1. 我的方法是否正确,如果不正确,我该如何改进?
  2. 阻止*bot 和bot* 的正确语法是什么

在此先感谢

#Enable RewriteEngine
RewriteEngine On

# Stop the Nasties!!
RewriteBase /


RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR]
RewriteCond %{HTTP_USER_AGENT}  baiduspider [NC,OR]
RewriteCond %{HTTP_USER_AGENT}  baidu [NC,OR]
RewriteCond %{HTTP_USER_AGENT}  Baiduspider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Baiduspider* [OR]

RewriteRule ^.* - [F,L]

【问题讨论】:

  • 谢谢。那么,我将如何禁止目前似乎遍布我的网站的 bot 和 bot。
  • 对不起,我的文字没有正确输出。我如何禁止 asteriskbot 和 bot asterisk

标签: .htaccess bots


【解决方案1】:
RewriteEngine On 
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] 
RewriteCond %{HTTP_USER_AGENT} ^Zeus 
RewriteRule ^.* - [F,L]

是的,这是正确的方式......

而且,如果你想阻止任何 IP,那么举个例子:

Order Deny,Allow
Deny from 127.0.0.1

【讨论】:

    【解决方案2】:

    您可以将所有这些条件合二为一:

    RewriteCond %{HTTP_USER_AGENT} (autoemailspider|baidu) [NC]
    RewriteRule ^ - [F]
    

    NC 用于忽略大小写。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-17
      • 2018-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-28
      • 1970-01-01
      相关资源
      最近更新 更多