Struggeling with outbound-rule

34 views
Skip to first unread message

Martin Keiblinger

unread,
May 8, 2012, 6:29:03 AM5/8/12
to UrlRewrite
I'm currently having problems to keep the URL the user entered after
redirecting.

For example the default example doesn't work. The "rule" rule works
without problems, every /test/status call is redirected to rewrite-
status.

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


But the outbound-rule doesn't keep it's promise to prevent the end
user from seeing the rewrite-status in the URL field in the browser.
<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 thier
location bar and in hyperlinks
in your pages.
</note>
<from>rewrite-status</from>
<to>/test/status/</to>
</outbound-rule>

After calling http://127.0.0.1:8080/test/status I see
http://127.0.0.1:8080/rewrite-status in the browser. Why? And how can
I fix that?

Wim De Smet

unread,
May 10, 2012, 4:24:25 AM5/10/12
to urlre...@googlegroups.com
Hey,

On Tue, May 8, 2012 at 12:29 PM, Martin Keiblinger <mar...@moosify.com> wrote:
> But the outbound-rule doesn't keep it's promise to prevent the end
> user from seeing the rewrite-status in the URL field in the browser.
>    <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 thier
> location bar and in hyperlinks
>            in your pages.
>        </note>
>        <from>rewrite-status</from>
>        <to>/test/status/</to>
>    </outbound-rule>
>
> After calling http://127.0.0.1:8080/test/status I see
> http://127.0.0.1:8080/rewrite-status in the browser. Why? And how can
> I fix that?

You misunderstand what it does. It changes any URL on the page that
would normally point to /rewrite-status to point to /test/status. If a
user clicks that URL you will be 302 redirecting them to
/rewrite-status though, which is what a type="redirect" does. A 302
redirect is simply telling the user "don't go here, go here". Of
course then he sees the URL you give him there, being /rewrite-status.

If you wish to not redirect the user, you can use a forward (the
default), which _internally_ redirects the message to a different
handler, i.e. in your application server itself. For that to work, the
filter or servlet responsible for replying to the request *must* be
listening for FORWARD as well as for REQUEST. See the docs for a
configuration example.

regards,
Wim
Reply all
Reply to author
Forward
0 new messages