利用rewrite重写规则屏蔽蜘蛛抓取某个网站

我们都知道可以通过robots.txt来引导蜘蛛抓取内容,多个域名的时候可以301重定向转移权重,但有时候我们可能要特定某个域名不允许抓取,这个时候就需要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

  • 发表于 2020-11-25 20:38
  • 阅读 ( 2081 )
  • 分类:建站运营

0 条评论

请先 登录 后评论
东北大表哥
东北大表哥

自由职业

161 篇文章

作家榜 »

  1. 东北大表哥 161 文章
  2. 小鹄 1 文章
  3. 阿天 0 文章
  4. 新百胜在线 0 文章
  5. 刘明明 0 文章
  6. 个的德3 0 文章
  7. 铂天先生 0 文章
  8. 王达 0 文章