Dipak Saraf Dipak Saraf - 18 days ago 6
Apache Configuration Question

301 redirect for a WordPress site and subfolder to different domains

I have 2 WordPress installation for example abc.com and abc.com/new/

Now I am planning to move the site to their own domain, i.e abc.com >> xyz.com and abc.com/new/ >> KLM.com.

So I was wondering how to accomplish this using .htaccess and where we should have this redirect .htaccess?

Answer

Inside root .htaccess have this redirect rule as the first rule:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?abc\.com$ [NC]
RewriteRule ^ http://xyz-site.com%{REQUEST_URI} [R=301,L,NE]

Then inside /new/.htaccess have this redirect rule as the first rule:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?abc\.com$ [NC]
RewriteRule .* http://klm-site.com/$0 [R=301,L,NE]
Comments