apache tomcat 一个网站多域名的实现方法
2024-08-27 18:30:07
供稿:网友
windows下 C:/WINDOWS/system32/drivers/etc 文件夹内 hosts 里加上
127.0.0.1
127.0.0.1 bbs.domain.com
127.0.0.1
127.0.0.1 bbs.domain.com
127.0.0.1
127.0.0.1 bbs.domain.com 其中 与 bbs.domain.com 共享同一个网站,目录为 D:/web/bbs/webapps/ROOT
在Apache 的 conf/httpd.conf 里修改
<VirtualHost *:80>
ServerName
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
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
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 appBase="webapps/ROOT"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="." path="" reloadable="true"/>
<Alias> bbs.domain.com </Alias>
<Host appBase="webapps/ROOT"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="." path="" reloadable="true"/>
<Alias> bbs.domain.com </Alias>
</Host>
<Host 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>