方法很多,不过不外于基于IP及域名
基于IP
<VirtualHost 127.0.0.1:80>
ServerAdmin
webmaster@dummy-host.example.com
DocumentRoot /www/docs/dummy-host.example.com
ServerName dummy-host.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
基于域名与其非常类似
不过这些都不推荐,个人推荐采用动态基于域名的虚拟主机
复制内容到剪贴板
代码:
NameVirtualHost *
AllowOverride None
Alias /error/ "E:/Tmp/error/"
AllowOverride None
Options IncludesNoExec
AddOutputFilter Includes html
AddHandler type-map var
Order allow,deny
Allow from all
LanguagePriority en cs de es fr it ja ko nl pl pt-br ro sv tr zh
ForceLanguagePriority Prefer Fallback
ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
UseCanonicalName off
VirtualDocumentRoot E:/wwwroot/%2/%1
DirectoryIndex index.htm index.html index.php
ServerSignature Off不过需要打开apache的一些加载模块。
如下:
LoadModule alias_module modules/mod_alias.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
版本不一样,以上可能会不一致