apache2.2多域名绑定不同目录,将代码放在httpd.conf最后
NameVirtualHost *:80
<VirtualHost *:80>
ServerName wo.com
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName wozine.com
DocumentRoot /www/otherdomain
</VirtualHost>
*号为ip,servername为域名,documentroot为网站目录,例子中为相对apache目录。也可写完全目录,如:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName wo.com
ServerAlias www.cq.com www.gd.com #让多个域名绑定到同一空间
DocumentRoot D:/马永占/myz
ErrorLog D:/马永占/myz/logs/ #虚拟主机发生错误时要记录在哪个目录,可不设
</VirtualHost>
<VirtualHost *:80>
ServerName wozine.com
DocumentRoot D:/隆隆/myz2
</VirtualHost>
最后重启apache
(亲测可行-moqiang02注意:DocumentRoot使用绝对路径)