例:主机IP是:192.168.1.1
你的主机上有三个域名:
http://www.a.com/ 网页文件放在E:\web\www\1
http://www.b.com/ 网页文件放在E:\web\www\2
http://www.c.com/ 网页文件放在E:\web\www\3
在apache的httpd.conf中加入
#设置不同的域名到不同的目录
NameVirtualHost 192.168.1.1
<VirtualHost 192.168.1.1>
ServerName http://www.a.com/
DocumentRoot "E:\web\www\a"
</VirtualHost>
<VirtualHost 192.168.1.1>
ServerName http://www.b.com/
DocumentRoot "E:\web\www\b"
</VirtualHost>
<VirtualHost 192.168.1.1>
ServerName http://www.c.com/
DocumentRoot "E:\web\www\c"
</VirtualHost>
重起,就ok 了.
Apache VirtualHost Example
<VirtualHost *:80>
ServerAdmin linuxpk@msn.com
DocumentRoot /home/linuxpk/web/
ServerName linuxpk.com
ServerAlias www.linuxpk.com
DirectoryIndex index.htm index.html index.php
DefaultLanguage zh-CN
AddDefaultCharset GB2312
ErrorDocument 404 http
://www.linuxpk.com/error.htmlErrorLog home/linuxpk/log/dummy-linuxpk.com-error_log
CustomLog home/linuxpk/log/dummy-linuxpk.com-access_log commom
<Directory "/home/linuxpk/web/">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfDefine PHP>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir none
php_admin_value session.save_path "/usr/local/tmp/php/session"
php_admin_value open_basedir "/home/linuxpk/web/;/usr/local/tmp/php"
</IfDefine>
</VirtualHost>