apache tomcat webserver
by sag2662 from LinuxQuestions.org on (#6M4XG)
Hi all,
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
Code:<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]
</Host>
</Engine>
</Host>
</Engine>
</Host>
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
Code:<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]
</Host>
</Engine>
</Host>
</Engine>
</Host>