- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 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 标签的正下方
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
在 $CATALINA_HOME/conf
目录下创建了一个 rewrite.config
RewriteRule ^/abc /myapp
其中 http:/host:port/myapp
是一个工作的网络应用程序。
所以现在当我转到 http://host:port/abc
时,我希望被重定向到 http://host:port/myapp
但我得到取而代之的是 404 请求的资源不可用
。
它看起来甚至没有读取我的 rewrite.config 文件。 logs 目录中的访问日志仅报告 "GET/abc HTTP/1.1"404 1000
,没有更多详细信息。
我错过了什么?谢谢
最佳答案
在 Tomcat 文档中 http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html是写的
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.
所以尝试将 rewrite.config
移动到 $CATALINA_HOME/conf/Catalina/localhost
小提示:您可以在 rewrite.config
中拼错某些内容(例如 xxRewriteRule
),然后如果 tomcat 读取此文件,它会失败。我认为在你的情况下,即使你拼错了某些东西(因为它没有被阅读),tomcat 也会启动。
关于Tomcat 8.0 重写阀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26932253/
在同一个 Tomcat 上下文配置中是否可以有多个 validator Valves?我知道你可以通过 CombinedRealm 拥有多个领域,但是不同的身份验证方法呢? 我必须更新 Web 应用程
我写了一个Tomcat valve,配置在server.xml里。到目前为止,一切都很好。但是,我希望阀门的数据成员之一是 Spring 管理的 bean。那么,我怎样才能使阀门也由 Spring 管
我是一名优秀的程序员,十分优秀!