HTTP 301 The Redirect Basics
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
Recent Comments
60
Penalized is a big word, but using a 301 is more SEO friendly than using a canonical... So, let's say: you will get a candy when you use a 301 and you will not get that candy when you use a canonical...
But you will not be severely penalized when you use a canonical...
;-)
Hope this helps...
Then you will have a lot of 404 errors or your old pages and content will still be visable for the visitors if they are not redirected from it...
https://en.wikipedia.org/wiki/HTTP_404
Grtz,
Bert
Oh no I changed the title and the url. The old url won't redirect. I don't care now cause it's ranked 400 or something. Should I redirect these to the new url? Seems like a waste of time.
Then this is indeed a better solution, cause you mean the cannonicals I suppose?
(And also SEO is better with 301's)
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!
Excellent work Bert! Keep up the good work! Thank you for all the work you put into this missive of information! Much appreciated!
This is something I really want to learn, these editing code stuff, but so nervous to do so. Thanks Bert.
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
See more comments
Thank you Bert, a very good piece of information!
You're very Welcome!