Tomcat对应多个子域名的配置

2018-12-04  本文已影响11人  开发者阿俊
<Host name="localhost" debug="0" appBase="D://Tomcat 5.0//webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       <Alias>localhost.com</Alias> 
       <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
            timestamp="true"/>
        <Context path="" docBase="D://Tomcat 5.0//webapps//gg"  reloadable="true" caseSensitive="false" debug="0"></Context>
</Host>

<Host name="one.localhost" debug="0" appBase="D://Tomcat 5.0//webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       <Alias>one.localhost.com</Alias> 
       <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
            timestamp="true"/>
       <Context path="" docBase="D://Tomcat 5.0//webapps//kk//a"  reloadable="true" caseSensitive="false" debug="0"></Context>
</Host>

<Host name="two.localhost" debug="0" appBase="D://Tomcat 5.0//webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       <Alias>two.localhost.com</Alias> 
       <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
            timestamp="true"/>
        <Context path="" docBase="D://Tomcat 5.0//webapps//kk//b"  reloadable="true" caseSensitive="false" debug="0"></Context>
</Host>


因无域名解析服务器,所以在hosts上配,来模拟dns解析.

10.1.1.241 localhost 指向gg文件夹
10.1.1.241 localhost.com 指向gg文件夹
10.1.1.241 one.localhost 指向a文件夹
10.1.1.241 one.localhost.com 指向a文件夹
10.1.1.241 two.localhost 指向b文件夹
10.1.1.241 two.localhost.com 指向b文件夹

如:http://localhost:8080/

    http://localhost:8080/first

    http://localhost:8080/second

对应的配置如下:

<Host name="localhost" debug="0" appBase="D://Tomcat 5.0//webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
       <Alias>localhost.com</Alias> 
       <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
            timestamp="true"/>
        <Context path="" docBase="D://Tomcat 5.0//webapps//Root"  reloadable="true" caseSensitive="false" debug="0"></Context>

        <Context path="/first" docBase="D://Tomcat 5.0//webapps//first"  reloadable="true" caseSensitive="false" debug="0"></Context>
        <Context path="/second" docBase="D://Tomcat 5.0//webapps//second"  reloadable="true" caseSensitive="false" debug="0"></Context>
</Host>
上一篇下一篇

猜你喜欢

热点阅读