HTTP 301 The Redirect Basics

Last Update: January 26, 2016

Hello,

Often we hear to use a redirect when a webpage is not reachable anymore or a URL is changed. But I thought it might be handy for a lot of people to list the basics of such a redirect.

$


First of all: When do you use a Redirect?

  • As default – this is the preferred method for every page redirection.
    (You can also use canonical URL’s but the 301 redirect is the preferred method.)

  • For pages that are permanently moved or replaced.

  • Domains that are permanently moved (acquisitions, rebranding, etc.).

  • 404 pages and expired content (when there is still relevant content or the page still exists).


Why?

The most important search engines are cracking down on websites that use sneaky redirects or point multiple domains to the same content, without using a proper redirect. The 301 permanent redirect is therefore also known as a search engine friendly redirect.


Where?

The best practice is to create the 301 redirect at the.htaccess file.
This file is located in the HttpDocs folder of your site, you can access this file easily thru an FTP client and edit the file as a text file.

To use the .htaccess file your website has to be on an Apache (Linux, Unix) based server. Here at WA this is the case, so for everybody with their site hosted on WA, this procedure can be applied.
If you use another hosting and you are unsure, then a simple header check will indicate your server type.

You can use this link to do this: http://tools.seobook.com/server-header-checker/

But you can also use your SEO plugin (I think the all in one has this possibility also), for Yoast you do it like this:
http://kb.yoast.com/article/305-how-to-edit-htacce...


How to setup a 301 Redirect

The basic code for redirecting is:
Redirect 301 old_location new_location

Redirect a single page:
Redirect 301 /oldpage.php http://www.yoursite.com/newpage.php
Redirect 301 /oldpage2.php http://www.yoursite.com/folder

You have moved your domain to another site / domain name:
Then you actually want to redirect the whole site, replace, of course, the previoussite and newsite values with the real values.
These 4 lines have to be added in the .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^previousSite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.previousSite\.com$
RewriteRule ^(.*)$ "http\:\/\/newSite\.com\/$1" [R=301,
L]

That is about it for the basics, of course, a lot more can be said about this redirection method. But when you understand the above well, then you can go already a long way with this knowledge...

I hope you liked this piece of info... ;-)

Grtz,
Bert

Join the Discussion
Write something…
Recent messages
paulgoodwin Premium
Thanks Bert as redirects slow down page loading speeds so this is good to know
Reply
AngelsBird Premium
Then this is indeed a better solution, cause you mean the cannonicals I suppose?
(And also SEO is better with 301's)
Reply
Maestrob Premium
Hey Bert! Sounds like good info to know so I've book marked it for when I can understand it! Which proves that if you are ingnorant, then I am super ignorant! For now!
Reply
AngelsBird Premium
:-)
Glad you like it.... ;-)
Reply
MarionBlack Premium
Good info to know Bert. I've bookmarked this in case I ever need it.
Reply
AngelsBird Premium
Thank you Marion!
Reply
TopAchiever Premium
Excellent work Bert! Keep up the good work! Thank you for all the work you put into this missive of information! Much appreciated!
Reply
AngelsBird Premium
WIth pleasure TA! ;-)
Reply
PIOFJR Premium
This is something I really want to learn, these editing code stuff, but so nervous to do so. Thanks Bert.
Reply
AngelsBird Premium
You can do this!
I am really sure that this is very simple for you, once you 've done it once, you will do it with your eyes closed... ;-)

Grtz,
Bert
Reply
Top