利用rewrite重写规则屏蔽蜘蛛抓取某个网站
我们都知道可以通过robots.txt来引导蜘蛛抓取内容,多个域名的时候可以301重定向转移权重,但有时候我们可能要特定某个域名不允许抓取,这个时候就需要rewrite来控制。
如果要直接屏蔽蜘蛛抓取,可以参考我的另外一篇文章 点击查看
注:HTTP_USER_AGENT 里面是要屏蔽的蜘蛛,根据直接需要添加就可以了。
iis、apache的规则如下:
RewriteEngine on
RewriteCond%{HTTP:Host} xxx.xxx.com
RewriteCond%{HTTP_USER_AGENT}(baiduspider|googlebot)[NC]RewriteRule^(.*)$ -[F]
xxx.xxx.com域名不允许百度和谷歌蜘蛛访问。
iis7规则如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rulename="Block spider"stopProcessing="true">
<matchurl="(.*)"ignoreCase="false"negate="false"/>
<conditions>
<addinput="{HTTP_HOST}"pattern="^xxx.xxx.com$"/>
<addinput="{HTTP_USER_AGENT}"pattern="baiduspider|googlebot"/>
</conditions>
<actiontype="AbortRequest"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
附录:
常见蜘蛛名字:
google蜘蛛:googlebot
百度蜘蛛:baiduspider
yahoo蜘蛛:slurp
alexa蜘蛛:ia_archiver
msn蜘蛛:msnbot
bing蜘蛛:bingbot
altavista蜘蛛:scooter
lycos蜘蛛:lycos_spider_(t-rex)
alltheweb蜘蛛:fast-webcrawler
inktomi蜘蛛:slurp
有道蜘蛛:YodaoBot和OutfoxBot
热土蜘蛛:Adminrtspider
搜狗蜘蛛:sogou spider
SOSO蜘蛛:sosospider
360搜蜘蛛:360spider

共有 0 条评论