Tomcat Configuration for Removing webapps name from URL

To change Host Name Locally modify hosts file which is located under below specified path and add new hostname whatever you like for testing locally.


To modify URL and remove webapps name from url you have to do below steps.

Create below specified file under specified path and insert that code.

This for default localhost application.


<?xml version='1.0' encoding='utf-8'?>

<Context displayName="localhost" docBase="" path=""



For your custom application you have to add code as specified below.

Where $host is your custom web application.

Add a configuration file for the host

mkdir conf/Catalina/$host

cat >conf/Catalina/$host/ROOT.xml

<?xml version='1.0' encoding='utf-8'?>

<Context displayName="$host" docBase="" path=""



Main step is to add ROOT folder under your webapps/$host folder like specified below

$tomcatdir/webapps/$host/ROOT/all the files

Next You have to modify server.xml file to add context paths and host


<Server port="8005" shutdown="SHUTDOWN">

<!– Comment these entries out to disable JMX MBeans support used for the

administration web application –>

<Listener className="org.apache.catalina.core.AprLifecycleListener" />

<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />

<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>

<!– Global JNDI resources –>


<!– Test entry for demonstration purposes –>

<Environment name="simpleValue" type="java.lang.Integer" value="30"/>

<!– Editable user database that can also be used by

UserDatabaseRealm to authenticate users –>

<Resource name="UserDatabase" auth="Container"


description="User database that can be updated and saved"


pathname="conf/tomcat-users.xml" />


<!– Define the Tomcat Stand-Alone Service –>

<Service name="Catalina">

<!– Define a non-SSL HTTP/1.1 Connector on port 8080 –>

<Connector port="8080" maxHttpHeaderSize="8192"

maxThreads="150" minSpareThreads="25" maxSpareThreads="75"

enableLookups="false" redirectPort="8443" acceptCount="100"

connectionTimeout="20000" disableUploadTimeout="true" />

<!– Note : To disable connection timeouts, set connectionTimeout value

to 0 –>

<!– Define an AJP 1.3 Connector on port 8009 –>

<Connector port="8009"

enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

<!– Define the top level container in our container hierarchy –>

<Engine name="Catalina" defaultHost="localhost">

<Realm className="org.apache.catalina.realm.UserDatabaseRealm"


<Context path="" docBase="webapps/ca"

debug="5" reloadable="true" crossContext="true">

<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"

maxActive="100" maxIdle="30" maxWait="10000"

username="database_user" password="database_password" driverClassName="com.mysql.jdbc.Driver"



<Context path="" docBase="webapps/app1" debug="5" reloadable="true" crossContext="true"></Context>

<Host name="localhost" appBase="webapps/app2"

unpackWARs="true" autoDeploy="true"

xmlValidation="false" xmlNamespaceAware="false">


<Host name="testdomain" debug="0" appBase="C:/tomcat-5.5/webapps/app1" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

<Logger className="org.apache.catalina.logger.FileLogger"

directory="logs" prefix="testdomain_log." suffix=".txt" timestamp="true"/>






For as many applications you have to apply

Related Posts:

One Responses

Anand Kumar January 5, 2008 at 12:32 pm

Well can u give some more details about this.

Comments are closed.