IIS7.5如何限制某UserAgent 禁止访问
2016-05-05 23:36
330 查看
参见
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:
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.
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.
相关文章推荐
- [javaSE] 网络编程(TCP,UDP,Socket特点)
- android 常用的adb命令
- hdu 2993 MAX Average Problem(斜率dp)
- PHP 创建缩略图
- 点圆柱类设计(3)
- 小代码
- I/O调优
- POJ 3320 Jessica's Reading Problem(尺取法)
- c++内存
- 汇编--INT 10H功能
- 深入理解
- Spring 学习笔记(一)
- linux usb安装介质制作 create-a-usb-stick-on-windows
- java中的名字重用
- "USDToBaseCurrencyRate"拿什么拯救我的智商...
- Spring的构造请求类 SimpleClientHttpRequestFactory
- java单例模式
- 学习View第三步
- java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection
- 搭建服务器上的GIT并实现自动同步到站点目录(www)