网址重写是重定向,而不是在后端重写 [英] Url Rewrite is redirecting rather than rewriting in backend
问题描述
我认为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>
这篇关于网址重写是重定向,而不是在后端重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!