apache 2.2的,在.haccess中添加如下形式的规则


在网站根目录的.htaccess文件里,最上面添加以下代码,如果没有.htaccess文件就自行创建一个。

RewriteCond %{HTTP_USER_AGENT} AhrefsBot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} YandexBot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} YandexImages [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} MJ12bot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} RU_Bot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} Ezooms  [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} 008 [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} Yeti [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} BLEXBot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} Exabot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} YisouSpider [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} sandcrawlerbot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} ShopWiki [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} Genieo [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} Aboundex [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} coccoc [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} MegaIndex [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} spbot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} SemrushBot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} TwengaBot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} SEOkicks-Robot [NC]
RewriteRule .* / [F]

RewriteCond %{HTTP_USER_AGENT} WordPress [NC]
RewriteRule .* / [F]