View Full Version : Redirect URL keeping the query string

04-19-2007, 01:06 PM
I'm trying to redirect all requests to page1.php to page2.php keeping whatever querystring there is intact - but I cant seem to make it work.

I've tried

RewriteRule ^page1.php page2.php?{query_string} [PT]


RewriteRule ^page1.php?(.*) page2.php?$1 [PT]

Everything I've found on google is about removing the querystring but I want to keep it.

04-19-2007, 05:16 PM
A couple things that might help.

'qsappend|QSA' (query string append)
This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.

RewriteCond %{QUERY_STRING} ^cat\=([^&]+)\&product_id\=([^&]+)$

04-19-2007, 06:41 PM
Looks like I got it sorted - just dropped the ? from RewriteRule ^page1.php?(.*) page2.php?$1 [PT]

04-20-2007, 08:51 AM
can anyone give me a good linky on the various flags (eg. [PT]) that go at the end of the directive. I know what some of them mean but I'd like to see a comprehensive list

04-20-2007, 09:01 PM
The manual for mod_rewrite, linked above, has them all.