...

View Full Version : Redirect URL keeping the query string



NancyJ
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]

and


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


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

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

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
'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.

http://forums.searchenginewatch.com/showthread.php?t=3925
RewriteCond %{QUERY_STRING} ^cat\=([^&]+)\&product_id\=([^&]+)$

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

NancyJ
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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum