What Is A 301 Redirect?

A 301 redirect is a HTTP status code – a signal from a web server. It is a way of telling search engines (crawlers) and users browsers that the content has permanently moved to another page, triggering an auto-redirect to the new location. If it very commonly used, and very important for SEO.

A great example of where a 301 redirect is useful is to avoid 404 (page not available) error codes, which can happen if the user clicks a link that is no longer active. If a 301 is put in place, when the user, or a search engine crawler, clicks the link, then they will be directed to the new location of that content. Note that there’s a temporary version of the 3xx redirect – the 302 redirect. This is interpreted differently by Google.

301 Redirect Due To A URL Change

The 301 redirect is commonly used when a website changes its domain name.

For example: a pet store in London with a URL www.snazzystuff4petz.com who now can be found at www.londonpetstore.com. Their new URL is way more memorable and SEO friendly, especially with the SERP ‘London pet store’.

The 301 redirect will take users who enter the old domain over to the new one, and the website owner can start to build up their rankings as a result.

Benefits of a 301 redirect 

  • Allows you to make changes to pages without losing website visitors
  • Automatically redirects traffic
  • Creates a better user experience compared to the 404 error
  • Reduces your bounce rate
  • Link equity passes through to new URL
  • If implemented correctly, will preserve original page’s SERP rankings

Indicate Your Preferred Domain Name

You should use a 301 Redirect to indicate the preferred domain name. Doing so will avoid problems with how the Google-Bot indexes your website. It will also make sure no internal duplicate content arises due to canonicalization issues. 

If you’re unfamiliar with canonical warnings, essentially, Google is having trouble distinguishing which version of a page is the one you’d prefer people to access. For example, do you want www.website.com or www.website.com/index to be the version that ranks? Removing this confusion will greatly aid your SEO efforts. 

Setting Up A 301 Redirect 

Setting up a 301 redirect is quite technical, so be sure to consult a developer if you’re unsure, as it may harm your website’s rankings if it’s not implemented correctly. Alternatively if your website is on WordPress, redirect plugins are available. 

In this example, we will redirect all requests from http://domain.com/ to http://www.domain.com/. We set this up by editing the .htaccess file in the top-level folder of the web content.

Add the following source code, changing up the details so that they are relevant to your site, to your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

When implemented successfully, any request for a page on domain.com will be redirected to www.domain.com, using the HTTP status code 301. This also works for direct URLs, which would direct http://domain.com/file.html to http://www.domain.com/file.html.

More information on how to set up a 301 redirect is available in this page, including an option with PHP code.

The 301-redirect process

In the following chart you can see the technical steps of what happenes during a 301-redirect.

Graphic explanation of the technical steps of a 301-redirect
Graphic explanation of the technical steps of a 301-redirect

What happens during a 301-redirect?

  1. The Google-Bot would like to get the file “abc.html” from the domain “domain.com”
  2. The Google-Bot sends a request to the webserver of the domain “domain.com” and asks for the file “abc.html”
  3. The webserver notices that the file “abc.html” does not exist anymore on the URL “domain.de/abc.html”. In addition, the webserver realises that there is an existing 301-redirect for the file “abc.html” to “xyz.html”
  4. The webserver returns the HTTP status code 301 (Moved Permanently) to the Google-Bot and points to the new URL, “domain.de/xyz.html”
  5. The Google-Bot understands that the content of the file “domain.de/abc.html” can now be found at the URL “domain.de/xyz.html”. From now on, when trying to access the file “domain.de/abc.html”, a user will be redirected automatically to “domain.de/xyz.html”

Internal Link Optimisation

Once you have chosen a preferred domain name, you should decide on a uniform internal link strategy and stick to it. The reason is that internal links are a powerful SEO tool, that can not only simplify your website’s navigation but emphasise keywords by using phrases as anchor text. Essentially, this acts to keep users on your website for longer and provide helpful resources related to the text. 

Changing up your internal link strategy can disrupt this process. So, say you decided on using www.domain.com as your preferred domain, then you should link all internal pages according to the following pattern: 

http://www.domain.com/a-directory/file.html. It is also advisable to use absolute paths instead of relative ones. This means that whenever you add a link, you use the entire URL as well as the host name

Conclusion

If a page on your website or your website as a whole has changed its location, 301 redirects will automatically take users to the new location and help search engines to understand the change. 

Without a 301 redirect, users would find broken links, error codes or even a website that won’t load at all, because the URL has changed. All of which would make your website slip down the rankings, and you’d lose website visitors too. 

But by redirecting users with a 301 redirect status code, you can make any necessary changes to your website without compromising on user experience or SEO rankings.

Steve Paine
28.11.2022