西数超哥博客
运维经验教程分享的博客

web.config各种屏蔽代码,屏蔽蜘蛛,屏蔽域名,屏蔽ip地址/ip地址段,允许ip访问代码

web.config各种屏蔽代码,屏蔽蜘蛛,屏蔽域名,屏蔽ip地址/ip地址段,允许ip访问代码 windows 第1张

只允许某段地址访问
<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”deny post” stopProcessing=”true”>
<match url=”(.*)” ignoreCase=”false” />
<conditions logicalGrouping=”MatchAll”>
<add input=”%{HTTP_X_FORWARDED_FOR}&amp;%{REMOTE_ADDR}&amp;%{HTTP_X_Real_IP}” pattern=”(118.113.)” ignoreCase=”false” negate=”true” />
</conditions>
<action type=”AbortRequest”  />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

屏蔽某段地址
<?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}&amp;%{HTTP_X_Real_IP}” pattern=”(8.8.4.4|8.8.8.)” />
</conditions>
<action type=”AbortRequest” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

限制某一个域名访问 

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”屏蔽ads.acesse.com访问”>
<match url=”^(.*)$” ignoreCase=”false” />
<conditions logicalGrouping=”MatchAll”>
<add input=”{HTTP_REFERER}” pattern=”ads.acesse.com” />
</conditions>
<action type=”AbortRequest” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

限制蜘蛛访问 

<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”Block spider”>
<match url=”(^robots.txt$)” ignoreCase=”false” negate=”true” />
<conditions>
<add input=”{HTTP_USER_AGENT}” pattern=”SemrushBot|Webdup|AcoonBot|AhrefsBot|Ezooms|EdisterBot|EC2LinkFinder|jikespider|Purebot|MJ12bot|WangIDSpider|WBSearchBot|Wotbox|xbfMozilla|Yottaa|YandexBot|Jorgee|SWEBot|spbot|TurnitinBot-Agent|curl|perl|Python|Wget|Xenu|ZmEu” ignoreCase=”true” />
</conditions>
<action type=”AbortRequest” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

赞(0) 打赏
声明:本站发布的内容(图片、视频和文字)以原创、转载和分享网络内容为主,若涉及侵权请及时告知,将会在第一时间删除。本站原创内容未经允许不得转载:西数超哥 » web.config各种屏蔽代码,屏蔽蜘蛛,屏蔽域名,屏蔽ip地址/ip地址段,允许ip访问代码

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏