I am trying to use the RewriteValve in Tomcat 8.0 http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
In $CATALINA_HOME/conf/server.xml, I added
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
right below the Host tag
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
Created a rewrite.config
in the $CATALINA_HOME/conf
directory with the following
RewriteRule ^/abc /myapp
where http:/host:port/myapp
is a working webapp.
So now when I go to http://host:port/abc
I expect to be redirected to http://host:port/myapp
but I get a 404 the requested resource is not available
instead.
It doesn't look like it is even reading my rewrite.config file. The access log in the logs directory just reports the "GET /abc HTTP/1.1" 404 1000
with no further details.
What am I missing? Thanks
In Tomcat documentation http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html is written
The rewrite valve can be configured as a valve added in a Host. See virtual-server documentation for informations how to configure it. It will use a rewrite.config file containing the rewrite directives, it must be placed in the Host configuration folder.
so try to move rewrite.config
into $CATALINA_HOME/conf/Catalina/localhost
Small hint: you can misspell something in rewrite.config
( e.g. xxRewriteRule
) and then if tomcat reads this file it fails. I think in your case tomcat starts even if you misspell something (because it is not read).
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