Apache Tomcat 9 rewrite valve not working

早过忘川 提交于 2019-12-24 18:28:13

问题


I have been trying to setup my tomcat 9 rewrite valve (on global level) without success, followed every tutorial I have found on the internet, but no matter how i configure my rewirte.config the valve simply does NOT work.

So I write the simplest rewrite.config I can think of, which contains only a single line:

RewriteRule ^test$ manager/test.jpg

So this rule simply means to rewrite http://localhost:8080/test to http://localhost:8080/manager/test.jpg

This file is placed inside $CATALINA_HOME/conf/Catalina/localhost I have verified that the valve is loaded properly in the localhost.2018-08-30.log log file:

30-Aug-2018 14:32:43.530 FINE [main] org.apache.catalina.valves.rewrite.RewriteValve.parse Add rule with pattern ^test$ and substitution manager/test.jpg

However when I restarted tomcat and tested it, the URL http://localhost:8080/test gave me a 404 error while the URL http://localhost:8080/manager/test.jpg loads the actual image correctly.

The access log shows:

127.0.0.1 - - [30/Aug/2018:14:39:50 +0800] "GET /test HTTP/1.1" 404 1078
127.0.0.1 - - [30/Aug/2018:14:42:34 +0800] "GET /manager/test.jpg HTTP/1.1" 304 -

So what did I miss?

来源:https://stackoverflow.com/questions/52090777/apache-tomcat-9-rewrite-valve-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!