On 11/06/2025 14:36, Troels Arvin wrote:
Hello,

On May 28th, Mark Thomas wrote:
Define the Valve at the web application level in the web application's META-INF/context.xml (nested under <Context>) rather than at the host level in server.xml

Rewrite rules for that web application then go in WEB-INF/rewrite.config

Then add

<WatchedResource>WEB-INF/rewrite.config</WatchedResource>

Thanks for trying to help. Unfortunately, I could not get that to work, either :-(

You might want to check what you did. I've just re-tested this locally with a clean Tomcat install and it works.

I added $CATALINA_BASE/webapps/ROOT/META-INF/context.xml with content:

<Context>
    <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
    <WatchedResource>WEB-INF/rewrite.config</WatchedResource>
</Context>


I added $CATALINA_BASE/webapps/ROOT/WEB-INF/rewrite.config with content:

RewriteRule ^/test.jsp  /index.jsp


I then started Tomcat and confirmed that http://localhost:8080/test.jsp returned the index page as expected.

I then modified the rewrite.config file to:

RewriteRule ^/test2.jsp /index.jsp

Watching the logs, I waited to see the log messages that indicated that the Context had been reloaded.

I then confirmed that http://localhost:8080/test.jsp returned a 404 and http://localhost:8080/test2.jsp returned the index page.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to