0

am trying to redirect (HTAccess) a URL based on the existance of a Querystring Paramater "ref". Only redirect when this exists with the prefix folder of "TMP" and page name "domain.html". The problem is that the redirect is working, but the Querystring isnt being passed on

e.g. http://www.olddomain.com/TMP/domain.html?ref=website-reference.com

RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/TMP/domain\.html$
RewriteCond %{QUERY_STRING} ^ref=([0-9]*)$
RewriteRule ^(.*)$ http://www.newdomain.com/?ref=%1 [R=301,NE,NC,L]

1 Answer 1

1

You can use:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^ref=
RewriteRule ^TMP/domain\.html$ http://www.newdomain.com/ [R=301,NE,NC,L]

With the same query string.

Sign up to request clarification or add additional context in comments.

1 Comment

worked first time, thank you so much for your excellent reply.

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.