301 redirects are a way of ensuring online traffic gets sent to the most up-to-date version of a URL. For example, if you delete a page on a website and your customers try to access that page and it’s no longer there, they get an error message, which isn’t a great user experience, right? So, what you do is permanently redirect the old URL to the new, or most appropriate, URL. This is known as a 301 redirect.
For example, if we wanted to redirect www.example.com/old to www.example.com/new, we would need to implement a 301 redirect from the old URL to the new one. Once this redirect has been implemented someone typing in www.example.com/old would land on www.example.com/new via the 301 redirect.
HTTP status codes
The 301 status code is one of many HTTP responses, meaning this URL has moved permanently and as such, should only be used for permanent redirection, so any links featuring the redundant URL should be redirected to the new URL provided.
To better explain this, it is worth briefly running through the process of a how a web page is presented (or served) to a user in the first place. Whenever your website server “serves up” a web page on your site to a visitor (either a human or search engine spider), it also serves a status code in the header. This information is served before the actual page content to inform your browser (or search engine) what the page (or file) contains, be it an image, HTML, PDF, video etc. The server status code is designed to inform the visitor or search engine the status of the page (file) in question.
You can check this yourself using a handy HTTP status checker that I use all the time for a quick visualisation of what’s going on (https://httpstatus.io).
To provide a real-life example, using this tool, paste our home page URL in https://www.hallaminternet.com and have a look at what information our server sends out when it receives the request.
The status code is shown as 200, essentially meaning that the web page requested is available and will be sent in response.
If a 301 redirect is used to redirect one page to another, the server will serve a status code of 301 Moved Permanently. In addition to the original page requested, this header response will return the URL of the new page location.
You can see this in effect using the status checker by changing our URL from https to http (the old, insecure version).
When to use 301 redirects
This information is essential if you’re moving content from one location to another, not least for search engines. If a search engine spider encounters a 301 redirect when crawling your website, it indicates to them the need to remove the old URL from their index, and replace it with the new one instead. This means that the new page should eventually replace the old page in the search engines index – and in the meantime, the old URL will redirect human visitors to the new URL whenever anyone attempts to access it.
If you don’t use a 301 redirect whenever you remove a page from your web server, search engines will be served a 404 Not Found error response code, which will result in the page in question being dropped from the search engine’s index completely over time.
The examples I have provided so far centre around moving a page from one URL on your site to another. However, 301 redirects can be used in a multitude of other scenarios, including:
- moving to a new domain (our previous website was Hallam.biz which is now redirected to Hallaminternet.com);
- cleaning up dynamic URLs and redirecting them to shorter search engine friendly versions;
- preventing duplicate content problems; for example, if you have multiple blogs written on the same subject and want to aggregate them into one blog.
The “canonical” attribute
To clear up some confusion, I’d like to address the difference between a 301 redirect and the rel=“canonical” attribute which can be applied to a web page header. The rel=“canonical” attribute is often misused as a 301 substitute.
A 301 is a permanent redirect that physically sends the user to the new page. Effectively: Show new “Page B” to all trying to access old “Page A”.
The rel=“canonical” attribute, on the other hand, is an indication or a suggestion for the search engine as to which version of a group of similar pages is preferred, to avoid duplication of content. Effectively: Show “Page A listing products by price” instead of “Page B listing products alphabetically”.
Therefore, the canonical tag should be used on pages which show near identical content to others (dynamic pages with multiple URLs of the same page as in the above example, domain Vs domain/index.html etc). Whereas 301s should be used for pages or domains that are being moved or replaced.
It is important to remember that changing even the smallest aspect of a page’s URL structure could cause that page to drop out of the search results entirely, which is why a 301 redirect is essential in maintaining the traffic/rankings that page may have been generating prior to the change in its URL structure.
It’s worth noting here that any differences in URLs are seen by search engines as separate pages. So all of the below are different variations of the same page.
For example, if you’re planning on developing a new website in the future, then it’s worth bearing in mind that new websites often mean new or different URL structures – maybe you’re moving to HTTPS (finally) or getting rid of a category or two? If over the years you’ve been producing some epic, engaging and relevant content, it is highly likely that these pages will have generated inbound links. Therefore, you need to ensure you transfer this authority across to your new URLs.
It might be reassuring at this point to reiterate the words of Google’s head of web spam, Matt Cutts, who states that “301 redirects can carry an identical amount of pagerank as that passed on by a link.”
Problems with 301 redirects
One major problem that I come across on a regular basis is that over time, 301 redirects become an ungodly mess (picture a Jackson Pollock painting). The main reason for this is that redirects get placed on top of redirects. For example:
Page A is old … redirect to shiny new Page B
Page B is old … redirect to shiny new Page C
Page C is old … redirect to shiny new Page D
Page D … you get it!
These are called redirect chains and they are bad because too many redirects stop links or page authority being passed on to the most relevant page. Essentially these need flattening out so that each old variant of a page redirects straight to the new one. For example:
Page A > Page D
Page B > Page D
Page C > Page D
Another common issue I see with 301 redirects is that they are used incorrectly. The most common manifestation of this is a website owner redirecting all old pages to the homepage (because it’s quicker). If you’re slimming down the content of your website, creating new pages or categories, you need to spend time making sure that each old page is being redirected to the most relevant new or existing page. Think about user experience and whether you’d be cheesed off if you wanted to find that epic page about redirects, only to be redirected to the homepage!
A final issue I will mention is not in the implementation of the redirects, but access. Sometimes it’s hard to get access to set up redirects because your developer tells you that you already have too many or maybe you just don’t have access to the server side. Thankfully, there are plugins that help you to manage redirects, such as Redirection as mentioned above, which can help with access.
How to set up 301 redirects
In the vast majority of cases, a web server’s behaviour is configured using what’s called a .htaccess file. This is a simple text file that sits in the root directory of your site (where your homepage also sits). For the purpose of implementing a 301 redirect, you will need to place a .htaccess file in your root directory (if one doesn’t already exist). You can create/edit an .htaccess file using any plain-text editor like Notepad or Textedit.
The file essentially contains a series of lines of instructions which for 301s are in the following format:
redirect 301 old page URL new page URL
Wildcards can be used to redirect groups of pages.
It is important to note that if you are moving multiple pages, you will need to include a redirect statement for every page you’re moving. Having a unique line for each page is the safest approach if you want to ensure that your commands are picked up by search engines.
There are very useful plugins you can use which take the coding element away from creating a 301 redirect file; for example, if you work with WordPress, the Redirection plug-in can help. However, if you have access to the .htaccess file you could also use 301 redirect generators.
Ed Ryan is a Senior Strategist at Hallam Internet with over 10 years of online marketing experience and a passion for PPC and SEO.Tweet