网站根目录下配置文件web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Block spider">
<match url="(^robots.txt$)" ignoreCase="false" negate="true"/>
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="Baiduspider|Baiduspider-image|Baiduspider-mobile|Baiduspider-video|Baiduspider-news|Googlebot|360Spider|Sosospider|YoudaoBot|YodaoBot|msnbot|msnbot-media|bingbot|ia_archiver|EasouSpider|JikeSpider|EtaoSpider|YisouSpider||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|Sogou News Spider|Sogou web spider|Sogou inst spider|Sogou spider|Sogou spider2|Sogou blog|Sogou Orion spider|Bing Spider|BaiDu Spider|DingTalkBot-LinkService|bidswitchbot/1.0|Wespe.de Spider|trendkite-akashic-crawler|Wespe.de Spider|Baidu-YunGuanCe-SLABot|Yandex Spider|CCBot/2.0+|MSN Spider|Yahoo Spider|Baidu-YunGuanCe-SLABot|Google Spider|webmeup-crawler.com|zhanzhang.toutiao.com" ignoreCase="true"/>
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
|