How to – 301 Redirects

301 Redirects are what tell your browser, “Hey! This page has permanently moved! Go to xyz location!”

This is useful if you are for some reason changing domain names or simply changing a few pages URLs. You don’t want to lose any “link juice” (the great Google Elixir) your old pages may have. Not to mention, if you have people linking to your site, you don’t want them to be reaching 404s!

301 Redirects to the rescue!

If you are using WordPress or another CMS there’s probably an easier to use plugin to do this, but I’m a huge fan of keeping plugins to an absolute minimum. Plus this is really simple to do.

Connect to your site via FTP and in the root directory you will generally find a file called .htaccess.

Open it up and copy a backup of the file locally.

On a new line add (the spacing has to be exactly as below):

Redirect 301 /old-site-page/ http://yoursite.com/new-site-page/

/old-site-page/ is a relative URL of your old web page and http://yoursite.com/new-site-page/ is an absolute URL of the page you want users to be redirected to.

Now what if /old-site-page/ had a subdirectory e.g. /old-site-page/sub-site-page/

The order of how you handle this is important because if you do this:

Redirect 301 /old-site-page/ http://yoursite.com/new-site-page/
Redirect 301 /old-site-page/sub-site-page/ http://yoursite.com/new-site-page/sub-site-page/

You’re going to have a bad time. The second redirect you declared won’t work as you have already redefined what “/old-site-page/” means.

Do it this way and have a good time:

Redirect 301 /old-site-page/sub-site-page/ http://yoursite.com/new-site-page/sub-site-page/
Redirect 301 /old-site-page/ http://yoursite.com/new-site-page/

Remember to test that it worked after you finished!

Obviously Hackerman GIF

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrShare on RedditBuffer this pageDigg thisEmail this to someone
Tell Your Friends

Leave a Reply

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