Url Rewrite重定向而不是在后端重写

时间:2014-03-27 18:46:15

标签: tomcat rewrite tuckey-urlrewrite-filter

我认为tuckey-urlrewrite-filter会在后端重写URL。因此,如果我输入地址栏http://localhost:8080/TEST/some/yo,我希望该地址留在地址栏中,但在Tomcat的后端处理它就好像我键入了http://localhost:8080/TEST/jspinwebinftest/?param=yo但是它重定向到{{ 1}}并在地址栏中显示。

如何才能让它只重写后端的URL?这是我的urlrewrite.xml:

http://localhost:8080/TEST/jspinwebinftest/?param=yo

1 个答案:

答案 0 :(得分:1)

我找到了答案。其实很简单。我需要删除tuckey网站上示例XML上的type="redirect"。我发现在重定向时,您必须在to标记中添加您的上下文应用,但在不重定向时,您不应该:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite
    PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
    "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite>
    <rule>
       <from>^/some/(.*)$</from>
       <to>/jspinwebinftest/?param=$1</to>
    </rule>
</urlrewrite>