开发者

Aliases for different contexts with Apache Tomcat 5.5

I am using tomcat 5.5 and I want to do the following:

If two web applications are deployed (let them be foo and bar) I want to be able to access them both with relative paths and by aliases.

localhost:8080/foo -> foo and foo.example.com -> foo

and respectively

localhost:8080/bar -> bar and bar.example.com -> bar

If I use different Hosts within the Engine and provide aliases -as the documentation dictates- then the aliased urls work fine, but not the relative ones. In order to have them both working properly I need an extra host "localhost" and declare the same contexts again. Here is my server.xml

<Engine name="Catalina" defaultHost="localhost">
    <Host name="foo.example.com">
        <开发者_如何学Python;Context docBase="webapps/foo" path="" workDir="work/Catalina/foo/_"/>
        <Alias>foo.example.com</Alias>
    </Host>
    <Host name="bar.example.com">
        <Context docBase="webapps/bar" path="" workDir="work/Catalina/bar/_"/>
        <Alias>bar.example.com</Alias>
    </Host>
    <Host name="localhost" appBase="webapps" autoDeploy="false" >
        <Context path="foo" workDir="work/Catalina/foo/_" />
        <Context path="bar" workDir="work/Catalina/bar/_" />
    </Host>
</Engine

Although it works this way, it seems that tomcat is loading each context twice. Is there any other way to achieve this?


It indeed loads the applications twice because you configured it that way. You'd need an apache httpd instance in front of tomcat to do some url rewrite magic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜