伪静态设置apache、iis规则屏蔽拦截蜘蛛抓取

[复制链接]
查看1638 | 回复0 | 2022-3-17 08:50 | 显示全部楼层 |阅读模式
如果是正常的搜索引擎蜘蛛访问,不建议对蜘蛛进行禁止,否则网站在百度等搜索引擎中的收录和排名将会丢失,造成客户流失等损失。
可以优先考虑升级虚拟主机型号以获得更多的流量或升级为云服务器(不限流量)。

Linux下规则文件.htaccess(手工创建.htaccess文件到站点根目录)
  1. <IfModule mod_rewrite.c>
  2. RewriteEngine On
  3. #Block spider
  4. 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]
  5. RewriteRule !(^robots\.txt$) - [F]
  6. </IfModule>
复制代码
Windows2008、2012或更高系统下规则文件web.config (手工创建web.config文件到站点根目录)
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3.   <system.webServer>
  4.    <rewrite>
  5.     <rules>
  6.      <rule name="Block spider">
  7.       <match url="(^robots.txt$)" ignoreCase="false" negate="true" />
  8.       <conditions>
  9.       <add input="{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|mail.RU|curl|perl|Python|Wget|Xenu|ZmEu" ignoreCase="true" />
  10.       </conditions>
  11.        <action type="AbortRequest"/>
  12.      </rule>
  13.     </rules>
  14.    </rewrite>
  15.   </system.webServer>
  16. </configuration>
复制代码

注:“{HTTP_USER_AGENT}”所在行中是不明蜘蛛名称,根据需要添加以"|"为分割。
  规则中默认屏蔽部分不明蜘蛛,要屏蔽其他蜘蛛按规则添加即可,附各大蜘蛛名字:
  google蜘蛛:googlebot
  百度蜘蛛:baiduspider
  百度手机蜘蛛:baiduboxapp
  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  

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

UID
1
贡献
387
丢币
38902
主题
4607
回帖
116
注册时间
2018-9-25
最后登录
2024-4-16