apache、iis6、ii7獨(dú)立ip主機(jī)屏蔽限制ip訪問(wèn)(適用vps云主機(jī)服務(wù)器)
注:
如果只屏蔽IP 8.8.4.4 則寫(xiě)(8.8.4.4)
如果只屏蔽IP段8.8.8. 則寫(xiě)(8.8.8.)
屏蔽多段中間用|隔開(kāi),如(8.8.4.4|8.8.8.)
Linux下 規(guī)則文件.htaccess(手工創(chuàng)建.htaccess文件到站點(diǎn)根目錄)
<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下 規(guī)則文件httpd.conf
若是安裝了我司助手環(huán)境請(qǐng)先把偽靜態(tài)組件開(kāi)啟,然后添加以下規(guī)則。
若是純凈版系統(tǒng),請(qǐng) 把偽靜態(tài)組件開(kāi)啟,然后在配置文件中按以下系統(tǒng)規(guī)則配置
#Block ip
RewriteCond %{HTTP_X_FORWARDED_FOR}&%{REMOTE_ADDR} (8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]
windows2008下 規(guī)則文件web.config (手工創(chuàng)建web.config文件到站點(diǎn)根目錄)
<?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>