View Full Version : mod_rewrite regex help

08-06-2011, 09:58 PM
Hi guys, I'm wondering if any of you can help me with a mod_rewrite regex.

I've devised a rule to handle specifying a userid value like: http://domain.com/directory/12345

Which is: RewriteRule ^([0-9]+)$ ?userid=$1 [L]

I want to adapt it so that if I need more parameters passed in I can do so using the regular ?var=1&loc=5 way.

Like this: http://domain.com/directory/12345?var=1&loc=5

I don't want to do something like this: http://domain.com/directory/12345/var/1/loc/5

I want to use the question mark and list the values in the standard URL way.

Thanks so much if you can help! :)

08-07-2011, 08:56 AM
You want a query string from the original request to be persisted across to the rewritten address? If so you just need the QSA flag.

RewriteRule ^([0-9]+)$ ?userid=$1 [QSA,L]

08-07-2011, 07:56 PM
wow that did it! thanks so much :)