Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat base URL redirection

Tags:

html

tomcat

Using tomcat, how do I get a request for http://www.mydomain.com to redirect to http://www.mydomain.com/somethingelse/index.jsp ? i haven't even managed to get an index.html to display from http://mydomain.com.

like image 202
Nathaniel Flath Avatar asked Sep 01 '09 17:09

Nathaniel Flath


People also ask

How to redirect Tomcat home page?

To redirect the default Tomcat home page to another URL, simply edit the index. html in the /CATALINA_HOME/webapps/ROOT/ directory, where CATALINA_HOME is your Tomcat directory.

How do I set up URL redirection?

Add a new URL redirectClick the URL Redirects tab. In the upper right, click Add URL redirect. In the right panel, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.

What is the Tomcat URL?

Use a browser to check whether Tomcat is running on URL http://localhost:8080 , where 8080 is the Tomcat port specified in conf/server. xml. If Tomcat is running properly and you specified the correct port, the browser displays the Tomcat homepage.


2 Answers

You can do this: If your tomcat installation is default and you have not done any changes, then the default war will be ROOT.war. Thus whenever you will call http://yourserver.example.com/, it will call the index.html or index.jsp of your default WAR file. Make the following changes in your webapp/ROOT folder for redirecting requests to http://yourserver.example.com/somewhere/else:

  1. Open webapp/ROOT/WEB-INF/web.xml, remove any servlet mapping with path /index.html or /index.jsp, and save.

  2. Remove webapp/ROOT/index.html, if it exists.

  3. Create the file webapp/ROOT/index.jsp with this line of content:

    <% response.sendRedirect("/some/where"); %> 

    or if you want to direct to a different server,

    <% response.sendRedirect("http://otherserver.example.com/some/where"); %> 

That's it.

like image 90
Viral Patel Avatar answered Oct 07 '22 13:10

Viral Patel


Name your webapp WAR “ROOT.war” or containing folder “ROOT”

like image 37
flybywire Avatar answered Oct 07 '22 12:10

flybywire