Hi Thomas,
Thanks for the fast response.
I added classname rewrite valeus in contex.xml file .
<!-- REWRITE VALVE -->
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
<!-- // -->
created rewrite.config so both of them is located under conf under
apache-tomcat.
So according to the documentaion they say context.xml should be placed
under webapps and rewrite.config file should be put in WEB-INF folder of
apache-tomcat
Thnks,
Ammu
On Thu, Apr 18, 2024 at 1:22 PM Mark Thomas <[email protected]> wrote:
> On 18/04/2024 12:05, lavanya tech wrote:
> > Hi Team,
> >
> > I am using "Tomcat 10.1" in our environment and I wanted to redirect url
> > from https://example.com to https://www.servercom:7777 and for this i
> > modified the server.xml as below in tomcat config, and the below
> > configuration doesnot seems to work. Does anyone has ideas. Please
> suggest.
> > The url alone https://www.servercom:7777/ already works. But just
> > redirection from the old to one doesnot.
> >
> > <Host name="example.com" appBase="app" unpackWARs="true"
> autoDeploy="true">
> > <Context path="" docBase="example" />
> > <Alias>example.com</Alias>
> > <!-- Add RewriteValve and RewriteRule here -->
> > <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
> > <Engine name="Catalina" defaultHost="localhost">
> > <Host name="example.com" appBase="app" unpackWARs="true"
> > autoDeploy="true">
> > <Context path="" docBase="example" />
> > <Alias>example.com</Alias>
> > <Valve
> className="org.apache.catalina.valves.rewrite.RewriteValve"/>
> > <Engine name="Catalina" defaultHost="localhost">
> > <Host name="example.com" appBase="app"
> > unpackWARs="true" autoDeploy="true">
> > <Context path="" docBase="example" />
> > <Alias>example.com</Alias>
> > <!-- Rewrite rule to redirect to
> > www.servercom:8080/example -->
> > <RewriteCond %{HTTP_HOST} example\.com [NC]
> > <RewriteRule ^/(.*)$
> > https://www.servercom:7777/example/$1 [R=301,L]
>
> 1. That isn't valid XML.
>
> 2. Where in the Tomcat docs does it say you can nest re-write rules in a
> Host element (or any other element)?
>
> > </Host>
> > </Engine>
> > </Host>
> > </Engine>
> > </Host>
>
> You need to configure the RewriteValve.
> https://tomcat.apache.org/tomcat-10.1-doc/rewrite.html
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>