阻止使用htaccess的MOD访问多个IP范围 [英] Blocking multiple ip ranges using mod access in htaccess

查看:380
本文介绍了阻止使用htaccess的MOD访问多个IP范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了Apache的网站上的指南,但我有点困惑,我试图禁止使用这种语法的一些范围:

I read the guide from apache site but I'm a bit confused, I'm trying to ban some ranges using this syntax:


order allow,deny
deny from 127.0.55.0/127.0.75.255
deny from 127.0.235.0/127.0.255.255
allow from all

不过,我认为这是不正常,可能是语法错误,或者我使用它在错误的道路,我应该在哪里写htaccess的这段文字?前的其他行或之后?在同一个htaccess文件是有一些mod-rewrite剧本太(防盗链)。

But I think it's not working properly, probably the syntax is wrong or I'm using it in the wrong way, where should I write this text in htaccess? before the other lines or after? in the same htaccess file there're some mod rewrite script too (for anti-hotlinking).

推荐答案

我来使用的 Apache文档

您可以使用IP /网络掩码对给出一个地址范围:

You can give an address range using ip/netmask pair :

deny from 127.0.55.0/24

然而,由于范围55 - 75不是2权力,我不知道如何做一个范围了出来。我想补充一些规则。

However, since range 55 - 75 are not power of two, I don't see how to make a range out of them. I'd add several rules.

order allow,deny
deny from 127.0.55.0/24  // Matches 55
deny from 127.0.56.0/21  // Matches 56 to 64
deny from 127.0.64.0/21  // Matches 64 to 71
deny from 127.0.72.0/22  // Matches 72 to 75

deny from 127.0.235.0/24 // Matches 235
deny from 127.0.236.0/22 // Matches 236 to 239
deny from 127.0.240.0/21 // Matches 240 to 255
allow from all

应该工作。

注:粘贴到htaccess的前取出后 // 的意见

NB: Remove the comments after // before pasting into htaccess

这篇关于阻止使用htaccess的MOD访问多个IP范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆