骤雨打新荷
» 游客:  注册 | 登录 | 会员 | 社区银行 | 股票中心 | 帮助

 

作者:
标题: 利用.htaccess功能限制中国的IP地址访问您的网站 上一主题 | 下一主题
txfzq
管理员




积分 33428
发帖 13147
注册 2005-5-26
状态 离线
#1  利用.htaccess功能限制中国的IP地址访问您的网站

IP Deny Manager
This feature will allow you to block a range of IP addresses to prevent them from accessing your site. You can also enter a fully qualified domain name, and the IP Deny Manager will attempt to resolve it to an IP address for you.

Note: You can specify denied IP adresses in the following formats:

10.5.3.333 Single IP Address
10.5.3.3-10.5.3.40 Range
10.5.3.5-40 Implied Range
10.5.3.3/32 CIDR Format
10. Implies 10.*.*.*
CP允许上述格式的IP地址,本人提供的是其中CIDR格式的IP地址.

进入CP,点击 IP Deny Manager 图标,在 IP Address or Domain 栏输入任意IP(例如: 58.14.0),点 Add 创建.
之后编辑.htaccess文件,看到类似

  Quote:
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
#The next line modified by DenyIP
order allow,deny
#The next line modified by DenyIP
#deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName xkcn.net.ru
AuthUserFile /home/xkcnnet/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/xkcnnet/public_html/_vti_pvt/service.grp

<Files 403.shtml>
order allow,deny
allow from all
</Files>

deny from 58.14.0

把 deny from 58.14.0 这里替换为附件中提供的IP地址即可.


需要注意的是:
若您不使用CP的 IP Deny Manager 功能而直接编辑.htaccess文件,还需要修改.htaccess文件中的其中一段语句.
否则,所有的IP都会被限制访问了

例如:

  Quote:
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName xkcn.net.ru
AuthUserFile /home/xkcnnet/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/xkcnnet/public_html/_vti_pvt/service.grp

把其中的
CODE:  [Copy to clipboard]
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
修改为
CODE:  [Copy to clipboard]
<Limit GET POST>
#The next line modified by DenyIP
order allow,deny
#The next line modified by DenyIP
#deny from all
allow from all
</Limit>
附件:block_chinese_ip_address.txt



2008-9-15 09:12
查看资料  发短消息   编辑帖子  引用回复


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转:  



[ 联系我们 - 骤雨打新荷 ]

Powered by Discuz! 2.5 © 2001-2005 Comsenz Technology Ltd.