欢迎您来到有益网络,开始互联网之旅!

');
有益网络

apache、ii7、iis8、iis10屏蔽限制ip访问(适用虚拟主机)

  • 来源:互联网
  • 时间:2019-09-27 17:06:57
  • 阅读17061

注:根据需求修改(8.8.4.4|8.8.8.)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下 

http://www.150cn.com/faq/53.html 先按此教程开启rewrite,然后添加以下规则。

#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}&amp;%{REMOTE_ADDR}" pattern="(8.8.4.4|8.8.8.)" />
                    </conditions>
                    <action type="AbortRequest" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>  
</configuration>


扫码关注公众号


会员 充值 客服 微信 工单
Top
微信公众号

微信扫一扫关注