利用rewrite重写规则屏蔽蜘蛛抓取网站
限制蜘蛛抓取可以用robots.txt,但是并非所有蜘蛛都会严格遵守,所以robots.txt也可以认为是“君子”协议,非“君子”可能一样会抓取,所以要用rewrite方式直接拒绝访问。 注:规则中HTTP_USER_AGE...
限制蜘蛛抓取可以用robots.txt,但是并非所有蜘蛛都会严格遵守,所以robots.txt也可以认为是“君子”协议,非“君子”可能一样会抓取,所以要用rewrite方式直接拒绝访问。
注:规则中HTTP_USER_AGENT默认屏蔽部分不明蜘蛛,要屏蔽其他可以进行修改,比如要屏蔽百度抓取,在HTTP_USER_AGENT里面添加baiduspider。
apache的规则规则如下:
<IfModulemod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "SemrushBot|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|mail.RU|curl|perl|Python|Wget|Xenu|ZmEu" [NC]
RewriteRule !(^robots\.txt$) - [F]
</IfModule>
windows2003 iis6规则:
RewriteCond%{HTTP_USER_AGENT}(SemrushBot|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|mail.RU|curl|perl|Python|Wget|Xenu|ZmEu)[NC]RewriteRule!(^/robots.txt$)-[F]
windows2008 iis7及以上版本web.config规则如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rulename="Block spider">
<matchurl="(^robots.txt$)"ignoreCase="false"negate="true"/>
<conditions>
<addinput="{HTTP_USER_AGENT}"pattern="SemrushBot|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|curl|perl|Python|Wget|Xenu|ZmEu"ignoreCase="true"/>
</conditions>
<actiontype="CustomResponse"statusCode="403"statusReason="Forbidden"statusDescription="Forbidden"/></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 条评论