Forum Moderators: phranque

Message Too Old, No Replies

Rewriting URL while preserving GET parameters

         

kajsng

2:03 pm on May 19, 2005 (gmt 0)

10+ Year Member



Hey. I need help rewriting a url and keeping the GET parameters. I need to rewrite:
/info/info2/anypage.php?something=5 to /info/anypage.php?something=5&id=2

The problem is that "?something=5" is optional. If I do a rewrite that always adds "&id=[the_number]" to the end, if the user leaves out "?something=5" then the request would be invalid ("/info/anypage.php&id=2", should be "/info/anypage.php?id=2").

How can I do that?

jdMorgan

2:19 pm on May 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the mod_rewrite documentation [httpd.apache.org], specifically, the [QSA] flag (Query String Append) of RewriteRule.

Jim