但有些 spider 不一定會理會 robot.txt
這部分可以用 urlrewrite 處理
<rule name="BlockBadBots" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="Baiduspider|claudebot@anthropic\.com|SemrushBot|Bytespider|serpstatbot" />
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Access denied." />
</rule>
Baiduspider : 百度
claudebot@anthropic.com : AI 掃網站
SemrushBot :
Bytespider : 字節跳動
serpstatbot
當然這也只能防君子不防小人
如果有心人刻意要掃網站,改它的 UserAgent 一樣可以掃