Change the path of application in Tomcat 6

stevey picture stevey · Mar 7, 2013 · Viewed 8.3k times · Source

I have my web application whose name is myApp.war. I copy my war file in $CATALINA_BASE/webapps. Now I can open my site using the URL:

http://localhost:8080/myApp/

However I want to change the path of my application (for example: newName), so I add a file ROOT.xml in $CATALINA_BASE/conf/Catalina/localhost.

Here is the code :

<Context docBase="myApp" path="/newName" debug="0" reloadable="true"/>

Now I use the new URL:

http://localhost:8080/newName/ 

but it doesn't work.

Answer

neonleo picture neonleo · Mar 7, 2013

Add the line below in your server.xml:

<Context docBase="myApp" path="/newName" debug="0" reloadable="true"/>

Like:

<Host>
  .
  .
  .
  <Context docBase="myApp" path="/newName" debug="0" reloadable="true"/>
</Host>
</Engine>
</Service>
</Server>

I would suggest another approach by using the Apache web server. Edit httpd.conf and write:

ProxyPass /newName http://localhost:8080/myApp
ProxyPassReverse /newName http://localhost:8080/myApp

You can access your app by http://localhost/newName.

Note: Apache runs on port 80 so you don't need to give the port number after localhost while accessing.