user2426542
user2426542

Reputation: 13

How to change htaccess to a parked domain while keeping the old links?

Parked the old domain to my new site (domain) in the htaccess following entry:

RewriteCond %{HTTP_HOST} ^(www.)?mynewsite.com$
RewriteRule ^(/)?$ mynewsite.com/index.php [L]
RewriteCond %{HTTP_HOST} ^old\-site\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old\-site\.com$
RewriteRule ^/?$ "http\:\/\/mynewsite\.com" [R=301,L]

Are old links that people will enjoy: old-site.com/support.php, old-site.com/en/index.php, old-site.com/en/support.php, old-site.com/msg/text.php When i click on it there is an error ERROR 404.

How to redirect them to the same addresses on the new domain? old-site.com/support.php -> mynewsite.com/support.php, old-site.com/en/index.php -> mynewsite.com/en/index.php

Upvotes: 1

Views: 102

Answers (1)

AbsoluteƵERØ
AbsoluteƵERØ

Reputation: 7880

If the old site is hosted as a separate domain (different vhost), in the old site's .htaccess:

RewriteCond %{HTTP_HOST} old\-site\.com$
RewriteRule ^(.*)$ http://mynewsite.com [R=301,L]

Then in the new site's .htaccess:

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* http://%{HTTP_HOST}/? [R=301,L] 

If they're both in the same virtual host (the old domain is an alias) then you can do this:

RewriteCond %{HTTP_HOST} old\-site\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mynewsite.com$
RewriteRule ^(.*)$ http://mynewsite.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* http://%{HTTP_HOST}/? [R=301,L]

Upvotes: 1

Related Questions