Contents

Firstly, what is a 301 redirect?

A 301 is a http status code. It is part of a series of different response codes that are sent from a web server and tells your browser what to display.

The most common and tangible http response code users are familiar with is the 404 (Not Found); most likely experienced from visiting a web page that doesn’t exist anymore.

These response codes are mainly invisible to the casual surfer as they are sent to the browser in the header. A http header defines the characteristics of the resource (file or page) to be served, containing information like a time stamp, how it should be cached and so forth – the header cannot be viewed in the HTML’s source code.

What does a 301 do?

A response code that begins with a 3 means it involves a redirection of some sort. So in this instance the 301 is a redirect. It is assigned by the W3C (the official body for web standards) as a permanent redirect with the title “Moved Permanently”.

A 301 permanent redirect tells the server to point your browser to another location; hopefully [1] redirecting you to a new page, file or resource.

When should I use a 301 redirect?

In most cases you would use it in place of an old, redundant file, or use it for a misspelled file name, or for replacing a removed page (or file), and point it to its new equivalent location whether it would be on the same site or another site.

For instance, say you have an old page that is frequently used by visitors to your site (called my-old-list-for-2020.html) that is no longer up to date and you want users on your new, more relevant page (say, my-new-list-for-2021.html), then you would replace my-old-list-for-2020.html with a 301 redirect pointing to the new page my-new-list-for-2021.html.

You can also use 301s for moving a whole site to another domain.

Also, sometimes (although rare), Google treats your prefixes (or subdomains) as a separate website, so for instance your non-www version of your site can get indexed (or vice-versa) and have your site crawled twice causing duplicate content issues. To prevent this it is wise to use a 301 redirect to your preferred version. For Google, you can set your preferred version using their Webmaster Tools.

Why should I use a 301 redirect?

As mentioned above it is mainly for your visitors who may have bookmarked a page, or have come through a search engine, or through a link from another web site – and you certainly don’t want them to get lost and disorientated by serving them an out of date page or a 404 Not Found page. A lost visit is a lost cause.

Where possible, you should always try to serve them the most relevant and/or up-to-date resource instead.

But more importantly! 301s and search engines…

Yes, there is one more important factor, and that is, again, to do with how search engines treat the 301 redirect.

From the logic that would normally be applied as to why you should use a 301 redirect in the first place, search engines, and in particular Google, have placed the same emphasis on how they display these resources in their results.

Why lose a page that was trusted and loved only for all that work to vanish in thin air.

By correctly using a 301 you can pass the love that was from the originating resource to the new resource (provided the search engines see the relevance). In terms of seo, this is very important.

Using 301 redirects is the most search engine-friendly way of achieving this.

What’s wrong with using a 302 instead?

By its definition a 302 is a temporary redirect. That means the resource should be back soon in its original location. Instances of this usage might be when a site or page is being updated, or the resource is down temporarily, and you don’t want visitors to see it for the time being, and instead serve them with an alternative page.

Most search engines do not treat 302s in the same respect as a 301 and do not pass the love. In the past 302s were exploited whereby you could hijack a site; saying the 302s new location was effectively the hijackers site – whoever’s the site may be. 301s are one way and the original page/site might take a while to be get recognition again in their own right.

When should I not use a 301?

On your own home page. The first moment you hit your main home page it should instead read 200 OK as a status code. Unless (unfortunately) you have a complicated folder structure whereby your home page resides in a subfolder called /home or /default, or something of that nature. In that case a 301 should be used and the new homepage’s location should finally give a 200 OK.

As mentioned earlier, having a 301 redirect from your non-www version to your www version (or vice versa) is accepted so as to not cause any duplicate content issues.

How do I know if I am using a 301?

There are several ways to check your headers. It is probably easier to type in the search term “http header checker”, select one of the many sites listed, and enter your web address (your full https://URL).

(I personally use Simon Carletti’s header checker as it is clean and quick.)

A screenshot of a 301 in progress

How do I implement one?

There are numerous useful resources available on the web for implementing 301 redirects. I’d feel that I am plagiarising someone’s code if I were to put any up myself as it is mostly the same code. I’d recommend webconfs.com version on 301 redirects, it is pretty reliable as a resource and has many different scenarios for different setups. It also has a tiny bit on non-www to www redirects.

For apache/php set ups the best method is through using htaccess and having greater control from using php in more complicated set ups.

Using Javascript and META refreshes will never do the job. They will always serve a 200 OK and then create a redirect. This is because the header has already been sent as a 200 OK, way before the META and Javascript can perform their redirect.

What should I watch out for?

Firstly, the destination url should almost in all cases read 200 OK.

Be cautious of excessive redirections or other status codes being displayed.

Using an online header checker, as mentioned above in how do I implement one, you should see, when entering your originating url, that it should first read 301 “Moved Permanently”, and then next with the new url, giving a status of 200 “OK”.

Sometimes a 302 might pop up from nowhere; usually, this is a misconfiguration [2] of the web server or a fault in the code. Older Microsoft IIS servers are notorious for serving 302s, contact support for help on that one.

If an online header checker returns a final 404 “Not Found” error, it is most likely that you have entered the wrong destination URL.

For better SEO click here

Remember, always check your http status codes.

Footnotes

^ [1] Hopefully is mentioned because the redirect’s destination should be correct. Usually, human error or a wrongly configured server results in a 301 turning into a 404 or a 302, or even worse, a 500. For more information on status codes and their definitions, visit: (https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)

^ [2] misconfiguration should be a word in the dictionary by now. Saying misconfiguration is already a mouthful, having to say incorrect configuration instead is plain awkward. Well, I suppose I learned something today.