views:

169

answers:

3

I build a war file called myapp.war and deploy it on Tomcat. I've changed the port from 8080 to 80 so I can then get to it at example.com/myapp (where example.com is my host). How can I get configure the application so when I go to example.com, it shows my app? I don't want to just redirect from example.com to example.com/myapp - I don't want to have the myapp in the URL. Do I have to set up Apache to serve the pages like this, or can I do it with a virtual host in the Tomcat configuration?

A: 

Check out the Tomcat virtual hosting howto.

Asaph
+2  A: 

You don't have to setup an Apache front-end or to configure virtual hosting in Tomcat for this. Instead, just deploy your webapp to the "root context". To do this, refer to How do I make my web application be the Tomcat default application ? on the Tomcat Wiki. They describe the three possible methods so you'll be able to pickup the one that suits the best your needs.

Pascal Thivent
+1  A: 

All you need to do is name your war ROOT.war.

danben
No, this is not enough, you need to remove the current default application first (i.e. delete the ROOT directory) for this method.
Pascal Thivent
That's not true, Tomcat will expand the WAR and overwrite the ROOT directory (for all recent versions of Tomcat) if it is restarted.
danben
Oh, indeed, forget what I said. But it is worth mentioning that it will be overwritten then.
Pascal Thivent
True enough. But if he didn't know about ROOT.war before, then he's just got the default app there.
danben