Question

I am trying to write a general rule in /WEB-INF/urlrewrite.xml that will take in an arbitrary URI and append the identifiers that follow a root identifier as Name Value Pairs.

For Example:

localhost:8084/URLRewrite/Fruits/Yellow/Banana/banana.jsp

to become

localhost:8084/URLRewrite/Fruits/Yellow/Banana/banana.jsp&key0=Fruits&key1=Yellow&key2=Banana

I know that this will involve regular expressions as well as parameter ambiguity.

Something of similar flavor is like:

<rule>
    <from>^/world/([a-z]+)/([a-z]+)$</from>
    <to>/world.jsp?country=$1&amp;city=$2</to>
</rule>

Examples:

Input:

  <a href="/world/usa/nyc">nyc</a>

Output:

  <a href="<%= response.encodeURL("/world.jsp?country=usa&amp;city=nyc") %>">nyc</a>

Any help or suggestions would be greatly appreciated.

No correct solution

OTHER TIPS

Try this:

<rule>
    <from>^/world/([a-z]+)/([a-z]+)$</from>
    <to type="redirect">/world.jsp?country=$1&amp;city=$2</to>
</rule>

Maybe you're missing the attribute type with value redirect in your configuration file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top