Pirzada
Pirzada

Reputation: 4713

Require fix for Tuckey URLRewrite filter rules

I am trying to understand tuckey urlRewrite to write a rule but am unable to do it.

I have a Servlet that has URL Pattern defined @WebServlet("/user/*"). At the load of Servlet I get URL like http://localhost:8080/Navigation/user/*.

How can I make a rule so whenever /user/ URL is loaded it should go to http://localhost:8080/Navigation/user/list. I tried this:

<rule>
    <from>^/user/*$</from>
    <to>/user/list</to>
</rule>

but this is not working.

Upvotes: 1

Views: 802

Answers (2)

Prakash K
Prakash K

Reputation: 11698

You can use something like this:

<urlrewrite use-context="true">
    <rule>
        <from>(.*)/user/(.*)$</from>
        <to type="permanent-redirect">$1/user/list</to>
    </rule>
</urlrewrite>

Where $1 represents anything that is before /user/ i.e. denoted by the first (.*).

A read through this manual might also help.

Hope this helps.

Upvotes: 4

sreejith
sreejith

Reputation: 725

try giving like this <to type="redirect">

Upvotes: 0

Related Questions