1

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!

1

1 Answer 1

2

I got it working (I hope) with the following:

RewriteEngine  on
RewriteCond %{REQUEST_URI} !newsite [NC]
RewriteCond %{QUERY_STRING} page
RewriteRule / /redirect/ [R,L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.