riksof-zeeshan
riksof-zeeshan

Reputation: 531

.htaccess redirect all pages and url from old domain to new domain

to be very honest I have zero knowledge with Regex and .htaccess

somewhere I found this code sample to redirect the user from old domain to new domain and it works fine

RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]
RewriteRule ^(.*)$ http://www.new.com/$1 [R=301,L]

But what is the issue here is when I access any page like www.old.com/courses it remains there rather of redirecting it to www.new.com/courses

It is a wordpress site and it has thousand of such sub/internal pages.

Upvotes: 0

Views: 468

Answers (1)

Jon Lin
Jon Lin

Reputation: 143846

Make sure you have those rules before any wordpress rules.

Upvotes: 1

Related Questions