redirect the whole domain and iinner pages in the same domain

virtualbyron

Elite Member
Jr. VIP
Joined
May 11, 2014
Messages
2,138
Reaction score
2,030
Hello mate,

I wish redirect the whole domain and specific inner pages in the same domain

For exemple :

301 redirect whole domain:
domain1.com to domain2.com

and

301 redirect for inner page like :
domain1.com/0001 to domain2.com/0001
domain1.com/0002 to domain2.com/0002
domain1.com/0003 to domain2.com/0003

How can I do that if are possible?

it is because I have the same page with the same keyword already classified with some nice links

Thanks a lot !

EDIT : I'll upload all the post in domain1.com to domain2.com it will not be any duplicate content issues?
 
Last edited:
You have to use a regex to rewrite the domain name and keep the same path. Something like this:

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

Before making any changes:

1. Backup your htaccess file.
2. Read some resources about "redirecting an Old Domain to a New Domain with .htaccess" (there are many reasons why the above code could fail and you may need to tweak it):

http://enarion.net/web/htaccess/migrate-domains/
http://www.inmotionhosting.com/support/website/htaccess/redirect-without-changing-url
http://301redirects.net/redirect-old-domain-to-new-website.php
http://stackoverflow.com/questions/...ain-to-new-domain-while-structure-of-pages-an
http://wpscholar.com/blog/redirect-an-old-domain-to-a-new-domain-with-htaccess/
 
Back
Top