How to 301 redirect keep url path, SEO & ranking when moving a website

This article was written by in January 7, 2015, & may not be posted on other sites!
Original source url for this article: How to 301 redirect keep url path, SEO & ranking when moving a website

How to 301 redirect keep url path & ranking when moving a website.
If you just moved your website from an old location to a new location and wish to tell search engines like Google to forward visitors to the new website, you can add a 301 redirect. This is how to 301 redirect & keep url paths when moving a website.

 

How to 301 redirect keep url path, SEO & ranking when moving a website

 

How to 301 redirect but keeping all url paths the same

Use this 301 redirect if you moved a whole website from www.old-domain.com to www.new-domain.com and all of the subpages and content have identical url paths on both websites. This means that the visitor will be sent from www.old-domain.com/subpage to www.new-domain.com/subpage. Add this code in your .htaccess on your old domain to forward users and keeping url paths the same when using 301 redirect:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.new-domain.com$1 [R=301,L]

You can also try this code:
RewriteCond %{HTTP_HOST} ^old-domain.com
RewriteRule ^(.*) http://new-domain.com/$1 [P]

How to 301 redirect but keeping all url paths using PHP
<?php
if ($_SERVER['HTTP_HOST'] != 'www.new-domain.com') {
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://www.new-domain.com".$_SERVER['REQUEST_URI']);
die();
}
?>

 

How to 301 redirect a single url

To 301 redirect a singel url using 301 redirect, add this code to your .htaccess on your old domain to forward visitors to the new page.
Redirect 301 /old-page.html http://www.new-website.com/new-page.html

If the above is not working for some reason, try this code:
RewriteRule ^old-page.html$ http://www.new-website.com/new-page.html [R=301,L]

How to 301 redirect a single url using PHP
Put this php code on the page you wish to forward and add your new location.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://new-website.com/");
die();
?>

 

301 redirect everything from old page to one single page

This 301 redirect code will send the visitor from any page on the old website to the index page of the new website. Put this code inside the .htaccess on your old domain.
Redirect 301 / http://www.new-website.com/

 

Changing a specific path when url don’t quite match, using 301 redirect

If the path doesn’t quite match on your old website vs your new website, use this code to change any given path:
RedirectMatch 301 ^/some-old-path/(.+)$ http://www.new-website.com/new-path/$1

 

The difference between 301 redirect and 302 redirect

Use 301 redirect
if your website is moving permanently to have search engines like Google also redirecting most of the worked in ranking & SEO.
Use 302 redirect
if your website is moving temporary to keep the SEO and ranking on your old website.

 

Why even use 301 redirect?

Don’t just delete your old website once your new one is up and running. Using a 301 redirect when moving a website from one location to another has its benefits:

  • You will keep most of the SEO, search engine ranking & earnings and pass everything to the new website immediately.
  • Duplicate content will hurt your ranking in Google search results. By redirecting, only the new website is counted for in search results and ranking. Duplicate content is no longer an issue.
  • All search results in a Google search showing your old website links will automatically redirect the visitor into the new website.
  • It takes search engines like Google up to 3 months to fully index all pages in a larger website. Using a 301 redirect, all your indexed pages in your old website will automatically send the user to your new website.
  • Google will also index your new website faster using 301 redirect.
  • You can automatically send visitors to the new website and the right page without them even noticing.

 

Spread the word

Facebooktwittergoogle_pluslinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *