在网站根目录的.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} DotBot [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} PetalBot [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] RewriteCond %{HTTP_USER_AGENT} SeznamBot [NC] RewriteRule .* / [F] RewriteCond %{HTTP_USER_AGENT} BUbiNG [NC] RewriteRule .* / [F] RewriteCond %{HTTP_USER_AGENT} Barkrowler [NC] RewriteRule .* / [F] RewriteCond %{HTTP_USER_AGENT} serpstatbot [NC] RewriteRule .* / [F] RewriteCond %{HTTP_USER_AGENT} MegaIndex.ru [NC] RewriteRule .* / [F] RewriteCond %{HTTP_USER_AGENT} DataForSeoBot [NC] RewriteRule .* / [F]