Apache中限制某些IP访问某个网页及配置某一目录只允许访问指定后缀的文件

查文档可知,在配置文件httpd.conf中可限制某些IP访问某个WEB目录,但只限定某一文件行不行呢?
 
做测试如下:
在httpd.conf中加入,
<Directory "/webroot/index2.php">
Order Deny,Allow
allow from 10.0.0.0/255.255.255.0 10.0.107.0/255.255.255.0
deny from all
</Directory>
 
重启WEB,在浏览器测试:
http://10.0.0.61/index2.php
 
显示如下:

Forbidden

You don't have permission to access /index2.php on this server.


Apache/2.0.59 (Unix) PHP/4.4.4 mod_jk/1.2.23 Server at 10.0.0.61 Port 80
 
 
看来可行。

Apache配置某目录只允许访问指定后缀的文件

<directory "XXXX\XXX\XXX">
order allow,deny
deny from all         
<filesmatch "\.(html|htm|css|js|jpg|gif|jpeg|png)$">
Order allow,deny             
allow from all         
</filesmatch> 
</directory>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值