apache 2.0 版本 虚拟主机 与 虚拟目录配置

1.配置虚拟主机

<VirtualHost *:80>

DocumentRoot E:/www
DirectoryIndex index.php index.html
ServerName localhost

</VirtualHost>

2.配置虚拟目录

<Directory "d:/www/zendstudio">
    Options Indexes FollowSymLinks Multiviews
    AllowOverride All
    Order Allow,Deny
    Allow from all
</Directory>

此时,注销掉APACHE默认的DocumentRoot设置:

#DocumentRoot "E:/www/apache/Apache2/htdocs"

#<Directory "E:/www/apache/Apache2/htdocs">
#Options Indexes FollowSymLinks
#AllowOverride None
#Order allow,deny
#Allow from all
#</Directory>

重启APACHE即可。

问题1:权限分配

Order Allow,Deny

Deny from 111.111.222.222

Allow from 111.111

权限先后,先ALLOW 后 DENY。   此时先执行ALLOW:Allow from 111.111。 后拒绝:Deny from 111.111.222.222。     Order Allow,Deny如果换成Order Deny,Allow --全部111.111都允许了,就不存在拒绝。

 问题2:ServerAlias使用

<VirtualHost *:80>
DocumentRoot "/var/www/"
ServerName WWW.XXX.COM
ServerAlias  *.xxx.com
</VirtualHost>

可以设置基于IP,与域名。   允许某个IP, 匹配规则达到泛解析域名。

原文地址:https://www.cnblogs.com/qunshu/p/3118434.html