2
votes

I want to redirect only home page of domain1.com to domain2.com keeping all the sub pages of domain1.com to domain1.com

I have added this in htaccess file:

RewriteRule ^$ http://www.domain2.com/ [R=302,L]

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

Everything is working fine except www.domain1.com/subpage.html still redirects to www.domain2.com.

Please provide a solution for it.

Thanks in advance!

1

1 Answers

1
votes

You can use:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.com$ [NC]
RewriteRule ^$ http://www.domain2.com/ [R=302,L]