Barton
Barton

Reputation: 143

HTAccess redirect Based on Query Parameter Fails?

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]

Upvotes: 0

Views: 39

Answers (1)

Croises
Croises

Reputation: 18671

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.

Upvotes: 1

Related Questions