waylonrobert
waylonrobert

Reputation: 104

301 Redirect to URL with query strings

I'm trying to redirect one URL to another URL. They are different domains, but both have query strings in their URLs. The sample URLs are:

Redirect: olddomain/faculty/profile?uID=123

to: newdomain/Faculty?id=024

This is what I've placed in the .htaccess file and it does not work (all modules necessary are installed and activated as there are other 301's without query strings that work without issue):

RewriteCond %{HTTP_HOST}  ^www\.olddomain\.tld$ [NC]
RewriteCond %{QUERY_STRING}  ^uID=123$ [NC]
RewriteRule ^faculty/profile$ http://newdomain/Faculty?id=024 [R=301,NE,NC,L]

What am I doing wrong?

Upvotes: 2

Views: 210

Answers (1)

anubhava
anubhava

Reputation: 784958

You need to add http:// also:

RewriteCond %{HTTP_HOST} ^www\.olddomain\.tld$ [NC]
RewriteCond %{QUERY_STRING} ^uID=123$ [NC]
RewriteRule ^faculty/profile$ http://newdomain/Faculty?id=024 [R=301,NE,NC,L]

And make sure this rule is placed at top just below RewriteEngine On.

Upvotes: 2

Related Questions