摘要

我无法启动UrlRewriteFilter并在Tomcat上运行。

问题

我只能从默认的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>

最佳答案

添加或删除尾部正斜杠(/)是否有所不同?可以尝试在规则标签集的from和to标签中同时或同时设置它。

10-05 23:10