Url Rewrite 是重定向而不是在后端重写 [英] Url Rewrite is redirecting rather than rewriting in backend

查看:18
本文介绍了Url Rewrite 是重定向而不是在后端重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I thought that tuckey-urlrewrite-filter would rewrite the URL in the backend. So like if I typed in the address bar http://localhost:8080/TEST/some/yo I expect that address to stay in the address bar but in the backend for Tomcat to process it as if I had typed http://localhost:8080/TEST/jspinwebinftest/?param=yo But instead its redirecting to http://localhost:8080/TEST/jspinwebinftest/?param=yo and showing that in address bar.

我怎样才能让它只在后端重写 URL?这是我的 urlrewrite.xml:

How can I get it to only rewrite the URL in the backend? Here is my urlrewrite.xml:

<?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 type="redirect">/TEST/jspinwebinftest/?param=$1</to>
    </rule>
</urlrewrite>

推荐答案

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

I found the answer. Pretty simple actually. I needed to remove the type="redirect" that was on the example XML at the tuckey website. And I found that when redirecting, you have to add your context app in the to tag, but when not redirecting, you should not:

<?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>

这篇关于Url Rewrite 是重定向而不是在后端重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆