Tomcat Base Url Redirection

Tomcat base URL redirection

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

URL Redirection/Rewrite on Tomcat

There is no RewriteEngine directive in the RewriteValve (cf. documentation), hence the parsing error you obtain.

The RewriteRule directive works almost as Apache's mod_rewrite directive with a twist: the pattern must match the entire URI path. Therefore you need to use:

RewriteRule /app/app.application(/.*)? /abc/app/app.application$1 [RL]

Tomcat URL Redirect Issue

Issue in rewrite.config file name.

Furthermore, Tomcat does not support dynamic/regex based contexts and that is because of well defined principles. If you have such a use case, I'd strongly advise figuring out the exact need for this and if you could improve the modelling.

Tomcat 9: valve redirection of http to https only works for base URL?

The RewriteRule was formatted for Tomcat 8 and was not suitable for Tomcat 9.
The equivalent rule that properly redirects all URLs in Tomcat 9 is:

RewriteRule ^/?(.*) https://server.url/$1 [R,NE,L]

Replacing server.url with the server's hostname.

Tomcat - redirect old context root to new context root

There is a Dir called ROOT under tomcat/webapps.

This ROOT "app" ends up getting invoked for those URLs that have "contextPath" different from the Directories under Webapps folder.

So you could:

  1. Create folder called "oldappname" directly under the "ROOT" folder.

  2. Create an index.html in that "oldappname" folder, and make it have a Javascript to Redirect Browser to the new URL.

Whenever the browser invokes http://servername/oldappname , tomcat will render: webapps/ROOT/oldappname/index.html

UPDATE:

You could do some interesting things with ROOT:

Tomcat 6: How to change the ROOT application

https://tomcat.apache.org/tomcat-7.0-doc/config/context.html



Related Topics



Leave a reply



Submit