<Files ~ "\.inc$"> Order allow,deny Deny from all </Files>
<Files ~ "reg.html"> Order allow,deny Deny from all </Files>
<Directory ~ "^/var/www/(.+/)*[0-9]{3}"> Order allow,deny Deny from all </Directory>
<FilesMatch \.(?i:gif|jpe?g|png)$> Order allow,deny Deny from all </FilesMatch>
<Location /dir/> Order allow,deny Deny from all </Location>
<Proxy http://cnn.com/*> Order allow,deny Deny from all </Proxy>
<Directory "/var/www/web/"> Order allow,deny Allow from all Deny from 10.0.0.1 #阻止一个IP Deny from 192.168.0.0/24 #阻止一个IP段 </Directory>
只允许某些IP访问,适合比如就允许内部或者合作公司访问:
<Directory "/var/www/web/"> Order deny,allow Deny from all All from example.com #允许某个域名 All from 10.0.0.1 #允许一个iP All from 10.0.0.1 10.0.0.2 #允许多个iP Allow from 10.1.0.0/255.255.0.0 #允许一个IP段,掩码对 All from 10.0.1 192.168 #允许一个IP段,后面不填写 All from 192.168.0.0/24 #允许一个IP段,网络号 </Directory>Apache:解决办法;
<Directory "/home/domain/public_html"> Options -Indexes FollowSymLinks AllowOverride All <Files ~ ".txt"> Order allow,deny Deny from all </Files> </Directory>