Re: Move URL parameter position

Splash Forums PrettyFaces Users Move URL parameter position Re: Move URL parameter position

#20569

Hey @trivial2k,

You can use a global rewrite rule for something like this, notice you would need two rules, one rule if there are no incoming query parameters, and another rule if there are:

<rewrite match="/^(cutegirl)(/.*/.*.jsf)$" substitute="$2?username=$1" />

<rewrite match="/^(cutegirl)(/.*/.*.jsf?.*)$" substitute="$2&username=$1" />

Which should do what you want:

http://www.xxx.com/($1)($2/*.*/*.jsf) -> http://www.xxx.com/*.*/*.jsf?username=cutegirl

I haven’t tested these specific rules, but they would look something like what I have written, using regular expressions:

This is equivalent to:

String newURL = ((String) request.getURI() + "?" + request.getQueryString()).replaceAll(match, substitute);

You can read more about regular expressions here:

http://ocpsoft.com/opensource/guide-to-regular-expressions-in-java-part-1/