windows下 C:\WINDOWS\system32\drivers\etc 文件夹内 hosts 里加上
127.0.0.1 www.domain.com
127.0.0.1 bbs.domain.com
127.0.0.1 www.domain.com
127.0.0.1 bbs.domain.com
127.0.0.1 www.domain.com
127.0.0.1 bbs.domain.com 其中 www.domain.com 与 bbs.domain.com 共享同一个网站,目录为 D:\web\bbs\webapps\ROOT
在Apache 的 conf\httpd.conf 里修改
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias bbs.domain.com
DocumentRoot "D:\web\bbs\webapps\ROOT"
<Directory "D:\web\bbs\webapps\ROOT">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias bbs.domain.com
DocumentRoot "D:\web\bbs\webapps\ROOT"
<Directory "D:\web\bbs\webapps\ROOT">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias bbs.domain.com
DocumentRoot "D:\web\bbs\webapps\ROOT"
<Directory "D:\web\bbs\webapps\ROOT">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
主要是增加了
ServerAlias bbs.domain.com
ServerAlias bbs.domain.com
ServerAlias bbs.domain.com在tomcat 的 D:\web\bbs\conf\server.xml 里修改
<Host name="www.domain.com" appBase="webapps\ROOT"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="." path="" reloadable="true"/>
<Alias> bbs.domain.com </Alias>
<Host name="www.domain.com" appBase="webapps\ROOT"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="." path="" reloadable="true"/>
<Alias> bbs.domain.com </Alias>
</Host>
<Host name="www.domain.com" appBase="webapps\ROOT"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="." path="" reloadable="true"/>
<Alias> bbs.domain.com </Alias>
</Host>
主要是增加了
<Alias> bbs.domain.com </Alias>