Reputation: 809
I would like to redirect visitors who go to:
http://example.com/?document=whatever&blah1=x&blah=y
To:
http://example.com/newsite/?document=whatever&blah1=x&blah2=y
So basically I want to (only) replace:
?document
With:
newsite/?document
And leave the rest of the URL unchanged. If the request does not contain ?document I just want to leave it alone.
EDIT
I've tried the following which does the redirect correctly, however I get stuck in a redirect loop because it still finds the query parameter next time around.
RewriteEngine on
RewriteCond %{QUERY_STRING} document
RewriteRule / /newsite/ [R,L]
Can I modify this so rewrite doesn't happen if "newsite" is in the URL, or maybe rename the document query parameter to redocument so it doesn't get picked up by the rule next time around? Any other suggestions?
Thanks!
Upvotes: 1
Views: 547
Reputation: 809
I got it working (I hope) with the following:
RewriteEngine on
RewriteCond %{REQUEST_URI} !newsite [NC]
RewriteCond %{QUERY_STRING} page
RewriteRule / /redirect/ [R,L]
Upvotes: 2