tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: Map domain names to different paths of a single webapp ?
Date Tue, 12 Jun 2012 19:29:43 GMT
Albert Kam wrote:
> Dear Tomcat Users !
> Let's say that i have this simple webapp using Tomcat 7, and let's say
> the context name is "albertzoo"

"albertzoo" is not the context here, it's a <Host>.
If you want that application to respond to the URL "" (thus the 
context "/"), you will have to use the ROOT webapp.

> And then, i would like a niche site for monkeys with it's own domain :

"" is the host. The context is "/".

> which is actually the same as :

In this one (barring tricks), "monkeys" is the context.

> But if the user is accessing through, i dont want
> them to see the in their browser

unless you do an external redirect, they should not see that.

> Is it possible to do with a single webapp context, or do i have to
> have different contexts(virtual hosts) for these different domains ?

I think that technically, you could monkey around to achieve that.  But it is probably a 
lot more trouble than it's worth (risks of double deployment, a mess when you undeploy or

want to manage your apps etc..).

Probably much better to use two separate <Host>, each with its own appBase (/webapps)

in one of them, you deploy your application as the ROOT (default) application (see the FAQ

for that); in the other, you deploy *a copy* of the same application as "monkeys" (and, 
supposedly, some other "animals" application as ROOT).
The only inconvenient is that when you update the monkeys application, you'll have to copy

it to both places.  But that will be much easier to manage, than to try some clever 
overlapping scheme which is going to come back and hit you somewhere..

Alternatively, if you feel adventurous, you could try a single <Host> with an Alias,
play with the URLrewrite filter (see and internal redirects, but... you 
have been warned.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message