apache的虚拟主机配置和指定目录的访问描述(
如果是wamp环境,打开wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf这个文件,前提是打开httpd.conf文件中的文件包含,代码如下“# Virtual hosts
#Include conf/extra/httpd-vhosts.conf”,去掉include前面的#,httpd-vhosts.conf文件末尾加入代码:
//配置虚拟主机
<VirtualHost *:80> DocumentRoot "D:/wamp/www/test" //这里设置虚拟主机 ServerName "123.com" //设置根域名 ServerAlias "www.123.com" //设置别名,这里可以添加N个子域名,如果泛解析到别的目录,另写一个,泛解析一样的:ServerAlias "*.123.com"
</VirtualHost>
//这里是目录描述 ,一般httpd.conf直接设置了根目录权限,如单个子目录有特殊需要可以单独添加
<Directory "D:/wamp/www/test">
Options FollowSymLinks AllowOverride All Order deny,allow order是优先级排序 deny,是禁止某些访问,allow是允许某些访问 Allow from all
</Directory>
下面是目录描述访问的例子:
下面是测试过的例子: -------------------------------- Order deny,allow allow from all deny from 219.204.253.8 #全部都可以通行 ------------------------------- Order deny,allow deny from 219.204.253.8 allow from all #全部都可以通行 ------------------------------- Order allow,deny deny from 219.204.253.8 allow from all #只有219.204.253.8不能通行 ------------------------------- Order allow,deny allow from all deny from 219.204.253.8 #只有219.204.253.8不能通行 ------------------------------- ------------------------------- Order allow,deny deny from all allow from 219.204.253.8 #全部都不能通行 ------------------------------- Order allow,deny allow from 219.204.253.8 deny from all #全部都不能通行 ------------------------------- Order deny,allow allow from 219.204.253.8 deny from all #只允许219.204.253.8通行 ------------------------------- Order deny,allow deny from all allow from 219.204.253.8 #只允许219.204.253.8通行 ------------------------------- -------------------------------- Order deny,allow #全部都可以通行(默认的) ------------------------------- Order allow,deny #全部都不能通行(默认的) ------------------------------- Order allow,deny deny from all #全部都不能通行 ------------------------------- Order deny,allow deny from all #全部都不能通行 ------------------------------- 对于上面两种情况,如果换成allow from all,则全部都可以通行! ------------------------------- Order deny,allow deny from 219.204.253.8 #只有219.204.253.8不能通行 ------------------------------- Order allow,deny deny from 219.204.253.8 #全部都不能通行 ------------------------------- Order allow,deny allow from 219.204.253.8 #只允许219.204.253.8通行 ------------------------------- Order deny,allow allow from 219.204.253.8 #全部都可以通行 ------------------------------- ------------------------------- order deny,allow allow from 218.20.253.2 deny from 218.20 #代表拒绝218.20开头的IP,但允许218.20.253.2通过;而其它非218.20开头的IP也都允许通过。 ------------------------------- order allow,deny allow from 218.20.253.2 deny from 218.20 #和上面的差不多,只是掉换的order语句中的allow、deny先后顺序,但最终结果表示全部都拒绝!