首页 > 技术文章 > IIS7、8 利用web.config配置屏蔽蜘蛛

zhaolongisme 2021-12-13 16:52 原文

网站根目录下配置文件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> 

 

推荐阅读