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?
+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
2010-01-08 23:56:40
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
2010-01-09 00:13:11
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
2010-01-09 00:24:27
Oh, indeed, forget what I said. But it is worth mentioning that it will be overwritten then.
Pascal Thivent
2010-01-09 00:29:58
True enough. But if he didn't know about ROOT.war before, then he's just got the default app there.
danben
2010-01-09 00:54:39