I have some web apps deployed on Tomcat, using the following configuration:

<Engine ...>
    <Host name="a.mycompany.com" ...>
    <Host name="b.mycompany.com" ...>
    <Host name="c.mycompany.com" ...>

For each of these apps, I can access them at the following two URLs:


Where x is a, b or c.

Is this normal, or have I done something wrong?


Yes, this is the default configuration.

You have deployed all 3 web apps on a single Tomcat instance - so they will be accessible by default as

http://<some-domain-url>/x where x = a,b or c

Are you looking to restrict the pattern to

http://a.mycompany.com/a or http://b.mycompany.com/b and

disallow http://a.mycompany.com/b ?

Then try nesting the web app via a <Context> element in the server.xml within your

<Host name="a.mycompany.com" ...>

Like so:

<Host name="a.mycompany.com" appBase="webapps"> 
    <Context path="/a" docBase="/a/"/> 

      <Host name="b.mycompany.com" appBase="webapps"> 
    <Context path="/b" docBase="/b/"/> 

If path is set to "" then you can get the app at the ROOT context, like a.mycompany.com instead of a.mycompany.com/a

  • What I want to achieve is a.mycompany.com being the only way accessing a - a.mycompany.com/a should give a 404 – Rich Dec 9 '10 at 12:23
  • I dont think that is possible with Tomcat alone. You need an Apache to front it to redirect to a 404 error page on that URL pattern – JoseK Dec 9 '10 at 12:31

Your Answer

