我正在尝试使用Tomcat 8.0中的RewriteValve http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
在$ CATALINA_HOME / conf / server.xml中,我添加了
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
在主机标签下面
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
使用以下rewrite.config在$CATALINA_HOME/conf目录中创build一个rewrite.config
RewriteRule ^/abc /myapp
其中http:/host:port/myapp是一个可用的webapp。
所以现在当我去http://host:port/abc我希望被redirect到http://host:port/myapp但我得到一个404 the requested resource is not available 。
它看起来不像它甚至读我的rewrite.config文件。 日志目录中的访问日志只是报告"GET /abc HTTP/1.1" 404 1000 ,没有进一步的细节。
我错过了什么? 谢谢
根据文档,如果在server.xml中configuration重写阀,则必须将rewrite.config文件放在“主机configuration文件夹”中。
主机文件夹是
$CATALINA_HOME/conf/Catalina/[host name]
或者在你的例子中
$CATALINA_HOME/conf/Catalina/localhost.