首页 > 其他 > 详细

IIS7.5如何限制某UserAgent 禁止访问

时间:2016-05-06 00:17:16      阅读:388      评论:0      收藏:0      [点我收藏+]

参见
Blocking Bots Based on User-Agent
http://moz.com/ugc/blocking-bots-based-on-useragent

http://serverfault.com/questions/312262/how-to-block-null-blank-user-agents-in-iis-7-5

If request filtering can‘t handle this, you can try ‘URL Rewrite‘ a free Add-On from Microsoft and pretty helpful anyways.

Create a rule like this:

<rule name="NoUserAgent" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_USER_AGENT}" pattern="^$" />
    </conditions>
    <action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You did not present a User-Agent header which is required for this site" />
</rule>

During a quick test this worked for both an empty User-Agent and a missing one.

I‘m using the regular expression ‘^$‘ which is only valid for an empty string.

You can also return a 404 or whatever else you want rather than a 403.

IIS7.5如何限制某UserAgent 禁止访问

原文:http://www.cnblogs.com/youlechang123/p/5463832.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!