Reputation: 2479
I have a simple tuckey rule to forward a path to another path, which looks like:
<rule>
<name>foo</name>
<condition name="user-agent">some condition based on device</condition>
<from>^/abc/(.*)$</from>
<to type="forward">/xyz/$1</to>
</rule>
As it is, I get a 404 when hitting /abc, but when I change type to "redirect", it works fine.
Is there anything wrong with the rule I defined?
Upvotes: 1
Views: 1026
Reputation: 9319
<to type="forward">/xyz</to>
is equivalent to
RequestDispatcher rq = request.getRequestDispatcher("/xyz");
rq.forward(request, response);
Forward happens on the server. The servlet container just forwards the same request to the target url, without the browser knowing about that. So your forward target url should in in the same context.
So it means, if /xyz/
URL is some external URL, not in your application context, you can't forward to it - instead you should redirect.
That said, I assume that your <to>
URL is external, that's why UrlRewriteFilter does not work. You can either change to redirect
or make sure that you want to forward to the URL which is within your application context.
Upvotes: 1