So basically I have made a webapp with the following url www.foo.com/foo (when deployed locally, my app has the following url localhost:8080/foo/). However, I would like to use www.foo.com instead. How can I go about doing this? Thanks! I have an apache2 web server and tomcat 7.
So basically I have made a webapp with the following url www.foo.com/foo (when deployed
Share
This is nothing to do with Spring, Apache, or Tomcat. It’s all about name resolution, and it’s done by lower-level things in the OS. You can force http://www.foo.com to resolve to your local machine by modifying the localhost line in your hosts file so it looks something like:
On Linux, that’s in
/etc/hosts. On Windows, you’ll find it atC:\Windows\System32\drivers\etc\hosts(thanks to @JBNizet for supplying this). Note that if you do this, though, you’ll no longer be able to get to the real http://www.foo.com because it’ll always resolve to your local machine.If you’re trying to do this because your app internally references “www.foo.com” and needs to have it resolve correctly in order to work, then you’re trying to solve that problem in the wrong way. You should pull those values out into some kind of external configuration so they can be set appropriately to the environment where the app is running.
Update: If this just about deploying to the root context of tomcat, that’s been answered several times, like in Tomcat 6: How to change the ROOT application.