我工作的网站主机内容不断被抓取和张贴在其他地方。
是否有可能重写URL,以便普通用户和白名单爬虫可以查看网站,但阻止访问无法识别的浏览器?
是的,你可以使用URL重写模块(我使用v2 ..但是它应该对v1有效。x也是,尽管我没有v1。X周围测试):
<system.webServer>
<rewrite>
<rules>
<rule name="UserAgentRedirect" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_USER_AGENT}" pattern="(iphone|ipod)" />
</conditions>
<action type="Rewrite" url="/special-page.aspx" />
</rule>
</rules>
</rewrite>
</system.webServer>
使用上述规则,所有来自iPhone或iPad(或任何其他浏览器/应用程序,在用户代理字符串中有iphone
或ipod
)的请求将被重写(内部重定向)到/special-page.aspx
。
如果有人真的想要抓取你的内容,我想这只是时间问题,直到他适应他的技术来假冒一个允许的浏览器。仍然为每个用户代理提供不同的内容是一个值得探索的好特性。