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.
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.
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.
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.
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
:
Open webapp/ROOT/WEB-INF/web.xml
, remove any servlet mapping with path /index.html
or /index.jsp
, and save.
Remove webapp/ROOT/index.html
, if it exists.
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.
Name your webapp WAR “ROOT.war” or containing folder “ROOT”
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With