Da11aS
Da11aS

Reputation: 465

Redirecting a Domain with a Get Variable to a New Domain with the htaccess file

I am trying to send /bn/referral.php?id=xxxxx to https://www.newdomain.com/index.php?referral=xxxxx

I have it currently set up like this, with no luck:

RewriteRule ^/bn/referral.php?id=([0-9]+)$ https://www.newdomain.com/index.php?referral=$1 [NC,L]

Thanks in advance for any insight to this issue.

Upvotes: 1

Views: 126

Answers (1)

RavinderSingh13
RavinderSingh13

Reputation: 133600

With your shown samples, attempts please try following .htaccess rules. Please make sure to clear your browser cache before testing your URLs. Also I am using here THE_REQUEST variable to handle both uri and query string together.

RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/bn/(referral)\.php\?id=(\S+)\s [NC]
RewriteRule ^ https://www.newdomain.com/index.php?%1=%2 [R=301,L]

Upvotes: 1

Related Questions