apache2.2配置文件中用的Order来控制权限,apache2.4已经改成了RequireAll,但是htaccess在apache2.2和apache2.4中都使用的是Order来控制权限。
权限说明
# 实例
<VirtualHost *:80>
ServerName www.qiang.com
DocumentRoot /var/www/qiang
<Directory "/var/www/qiang">
Order deny,allow
deny from 192.168.1.112
allow from all
</Directory>
</VirtualHost>
# 只拒绝1.0,然后允许所有
Order allow,deny # 规则顺序:先设置允许规则,后设置拒绝规则,最后的规则优先生效
Allow from all # 允许规则:先允许所有人访问
deny from 192.168.1. # 拒绝规则:唯独拒绝192.168.1.网段的用户访问(优先生效)
# 这样写就是只允许1.113,拒绝112和所有用户
Order allow,deny
allow from 192.168.1.113
deny from 192.168.1.112
# 拒绝112和所有用户
Order allow,deny
allow from 192.168.1.112
deny from 192.168.1.112
# 这样是拒绝所有
Order allow,deny
allow from 192.168.1.
deny from all
# 拒绝所有,只允许1.0网段访问
Order deny,allow # 规则顺序:先设置允许规则,后设置拒绝规则先级最高,最后的规则优先生效
deny from all # 拒绝规则:先拒绝所有人访问
allow from 192.168.1. # 允许规则:唯独允许192.168.1.网段的用户访问(优先生效)
# 这样写就会拒绝112,允许113和所有用户
Order deny,allow
deny from 192.168.1.112
allow from 192.168.1.113
# 允许112和所有用户
Order deny,allow
deny from 192.168.1.112
allow from 192.168.1.112
# 允许所有访问
Order deny,allow
deny from 192.168.1.112
allow from all # 优先生效