最近碰到几个流氓IP,一天扫描网站达几万次,恐怖!如果你是虚拟主机这个就非常实用了!
注:根据需求修改(8.8.4.4|8.8.8.)ip范围,替换掉你要屏蔽的IP
Linux下 规则文件.htaccess(手工创建.htaccess文件到站点根目录)
<IfModule mod_rewrite.c>
RewriteEngine On
#Block ip
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR} (8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]
</IfModule>
windows2003下 规则文件httpd.conf(在虚拟主机控制面板中用 “ISAPI筛选器自定义设置 " 开启自定义伪静态 Isapi_Rewite3.1 )
#Block ip
RewriteCond %{HTTP_X_FORWARDED_FOR}&%{REMOTE_ADDR} (8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]
windows2008下 规则文件web.config (手工创建web.config文件到站点根目录)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="band ip" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="%{HTTP_X_FORWARDED_FOR}&%{REMOTE_ADDR}" pattern="(8.8.4.4|8.8.8.)" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
--w9941为你呈现
fansart:这么复杂, 我来补充linxu主机的拒绝访问机制 用.htaccess
order deny,allow
deny from 115.238.252.182
也可以批量拒绝
order deny,allow
deny from 115.238.252.*
来源:seo优化网 转载注明出处!
新闻热点
疑难解答