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?

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

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.