Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect 301 + indexes

         

guy85

9:21 am on Sep 7, 2010 (gmt 0)

10+ Year Member



Hi all, please I need help regarding 301 redirect. We have 2 domain names. We have a site running on domain1, but now want the same site, content etc on domain2 instead. We have moved the DB of 1 to 2, so both have exact same content and permalinks.

We want to redirect domain1 to domain2 permanently. But also make sure all Google indexes of 1 is now seen as 2. That means domain1.com/about will be redirected to domain2.com/about - in all cases.

We have tried this code in .htaccess, but it doesnt seem to work. Server is Linux.

Options -Indexes
#Options +FollowSymLinks
#RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain1.com$[OR]
RewriteCond %{HTTP_HOST} ^domain1.com$
RewriteRule ^(.*)$ [domain2.com...] [R=301,L]

Ps can someone provide us with a code that will do the magic.

Many thanks

phranque

12:21 pm on Sep 7, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], guy85!

while your specific solution may ultimately require more, try this to start:
Options -Indexes +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} !^www.domain2.com$ RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]