摘要
我无法在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>
答案 0 :(得分:1)
添加或删除尾部正斜杠(/)会有所不同吗?可以尝试在规则标记集的from和to标记中同时设置它。
答案 1 :(得分:1)
@Mike是对的,改变
<from>/test/status/</from>
到
<from>/test/status</from>