【发布时间】:2011-12-12 22:42:38
【问题描述】:
总结
我无法在 Tomcat 上启动和运行 UrlRewriteFilter。
问题
我只能从默认的 urlrewrite.xml 文件中获取两个规则之一来工作。我遵循installation directions 没有太大问题,我没有更改任何默认值或弄乱配置文件。
示例
出站规则有效:http://localhost:8080/mysite/rewrite-status 成功将我带到我的 urlrewrite.xml 文件的描述页面。
但常规规则不起作用:http://localhost:8080/mysite/test/status 不会将我重定向到 http://localhost:8080/mysite/rewrite-status。我得到一个 404 结果。
我对这些规则的期望是错误的吗?有什么问题?
详情
这里是安装时自带的 urlrewrite.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN"
"http://www.tuckey.org/res/dtds/urlrewrite3.2.dtd">
<urlrewrite>
<rule>
<note>
The rule means that requests to /test/status/ will be redirected to /rewrite-status
the url will be rewritten.
</note>
<from>/test/status/</from>
<to type="redirect">%{context-path}/rewrite-status</to>
</rule>
<outbound-rule>
<note>
The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url)
the url /rewrite-status will be rewritten to /test/status/.
The above rule and this outbound-rule means that end users should never see the
url /rewrite-status only /test/status/ both in their location bar and in hyperlinks
in your pages.
</note>
<from>/rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>
</urlrewrite>
【问题讨论】:
-
我问了一个非常相似的问题;但还没有时间测试我得到的一个答案。你可以检查一下,看看这些信息是否有用:stackoverflow.com/questions/7218909/…
标签: apache web-applications tomcat