0

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" ...>
</Engine>

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

http://x.mycompany.com/
http://x.mycompany.com/x

Where x is a, b or c.

Is this normal, or have I done something wrong?

Rich
  • 1,333
  • 5
  • 27
  • 39

1 Answers1

1

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> 

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

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

JoseK
  • 455
  • 6
  • 13
  • What I want to achieve is http://a.mycompany.com/ being the only way accessing a - http://a.mycompany.com/a should give a 404 – Rich Dec 09 '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 09 '10 at 12:31