问:<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="301Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^ztqhzh\\.com$" />
</conditions>
<action type="Redirect" url="http://www.ztqhzh.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
上面是原web.config,如何添加规则屏蔽IP。需要屏蔽的IP段为(|180.163.220.|42.236.10.),windows2008主机设置屏蔽IP
答:您好,可将规则替换为如下即可,谢谢。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="301Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^ztqhzh\\.com$" />
</conditions>
<action type="Redirect" url="http://www.ztqhzh.com/{R:0}" redirectType="Permanent" />
</rule>
<rule name="band ip" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="%{HTTP_X_FORWARDED_FOR}&%{REMOTE_ADDR}&%{HTTP_X_Real_IP}" pattern="(180.163.220.|42.236.10.)" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>