301 vs 302 Redirects. Complete SEO Guide to Implement

301 vs 302 Redirects. Complete SEO Guide to Implement

Redirection is a basic Internet technology that allows one page to be accessed by multiple links. Even in 2020, redirecting HTTP requests of redirecting remains a rather confusing topic for webmasters and search engines. Redirection can be done at the link level, i.e. another link opens instead of one, and at the domain level.

For example, if you want users to be able to use several different addresses to come to your site: company.com, company.org, and company.us. To do this you can register the desired domain names, specify the main one, and set up permanent redirection for the others.

The most popular reasons for using redirects are:

  • an invalid, or non-existent link;
  • a new website or page;
  • temporary inaccessibility, for example, you are changing or repairing a page and you want to redirect the users until you finish working;
  • a disabled or deleted page, perhaps for old products or ones that you no longer produce;
  • switching to another CMS platform;
  • someone posts a backlink with an error or to a page that is currently unavailable, but you do not want to lose the weight of the link;
  • you are updating or changing the site navigation;
  • shortening a long link;
  • for preventing broken links when pages are moved;
  • to connect multiple domain names to the same site;
  • to connect similar domain names to the same site, for example, if you are taking into account the most common typos;
  • to protect personal data;
  • to protect forms from re-sent POST/ REDIRECT/ GET;
  • to redirect users to local or mobile versions of pages;
  • redirecting to a more secure protocol or implementing a security certificate, such as SSL;
  • for A/ B testing of different versions of pages, content, branding, etc.

Redirection is also often used by hackers, for instance:

  • for manipulating search services;
  • to deceive visitors;
  • to delete information about referral traffic;
  • for fraudulent schemes, such as phishing or malware distribution. Read more in our article What is SPAM and How To Protect Yourself.

As you can see, redirects cover a wide variety of tasks. Selecting the proper tool is half of the battle, so it is important to know the basic techniques for configuring redirects so the ranking and user experience on your pages do not suffer. These are the main types of redirects:

A Brief Description

Permanent Redirects: 301 and 308

HTML status codes 3018 and 308 apply if the page or resource has been moved and its new location will be used permanently. A permanent redirection is a great choice for changing the structure of a web page or migrating to a safer protocol. The 308 redirect was introduced in 2015 as a part of  RFC 7538. As with all innovations, not all browsers have supported the code. For example, Internet Explorer 11 is included in the distribution of Windows 7 and 8, but getting code 308 just displayed an empty page.

The difference between the processing of redirects 301 and 308 is in the client’s response (the browser). In particular, when receiving a 308 HTML status code, the client must repeat the same request on the redirected page. In other words, if you send a POST request and get a 308 redirect in the response, the browser must then perform a similar POST request on the page it is redirected to. A 301 HTML status code allows you to change the request method when redirecting, which is most often the case with clients. 

Thus, it is generally recommended to stick to 301 code for constant redirects to ensure better compatibility. But, if you are sure that all your clients will be able to interpret the newer code correctly and if the processing of POST requests is important, then you can use the 308 redirect.

Temporary Redirects: 302, 303, and 307


The HTTP/1.0 specification was released in 1996 and only included the 302 status code for temporary redirects. Although it was specified that clients are not allowed to change the request method in a redirected request, most browsers ignore the standard and always execute GET on the redirect URL. This is the main reason for the introduction of the additional status codes 303 redirect and 307 redirect in the updated HTTP/1.1 that was released in 1999.Temporary redirect codes
indicate that the page or resource of interest is available at a different address. That is, the life cycle of temporary redirects is limited by their end date and the caching of materials is not required. For instance, if one of your pages needs technical work, your best option is to set up a temporary redirect to the corresponding landing page. Temporary redirects are also recommended for submitting different versions of the content or entire sites, depending on the location, device, or other specific parameters of each user.

The HTTP 303 status code tells the client that the resource is temporarily available somewhere else and it explicitly instructs the user to execute a GET request for the new URL, regardless of the method that was originally being used. Status code 307 instructs the client to repeat the request with a different URL but using the same request method that they did with the original request.

In practice, browsers and search bots process code 302 the same as 303, which means that redirects are always executed as GET requests.

Although enough time has passed since the submission of status codes 303 and 307 in 1999, there are still clients that violate the standard and do not fulfill requests according to its specification. Therefore, similar to the situation with codes 301 and 308, in general, we recommend following the 302 redirect for compatibility reasons. 

The Impact on Search Engine Optimization

When a Google search bot encounters permanent redirects 301 or 308, the old version of the page is removed from the index and replaced with the updated one. It is natural to question if this affects the page’s weight for ranking. In this video,  Matt Cutts explains that the total link weight lost when using 301 redirects is approximately the same as any normal link. And in this tutorial, Matt Cutts clarifies whether or not there is a limit on the number of permanent redirect codes for a site or page. So, it is not necessary to worry about permanent redirects negatively impacting your ranking in SERP.

From Google’s perspective, temporary redirects are cosmetic. Because HTTP codes 302, 303, and 307 are ignored to some degree, the search engine knows that they are temporary.

The original page remains unchanged, its ranking parameters do not change, and not even a portion of its weight is transferred to the temporary links.

When using HTTP redirects, another aspect you should consider is its impact on performance. Each redirect is another HTTP request, meaning it adds another few hundredths of a millisecond to your page’s loading time. While one redirect will not hurt, you should avoid having redirect chains that are too long to not degrade the user experience, and if possible, reduce the load on the webserver.

What is a 301 redirect? A Description of HTTP 301 Status Code

The HTTP 301 status code indicates that a new permanent URL has been assigned to the target resource and that any future links to this resource should use the updated suggested URLs. The clients that support link editing should automatically update the data to match the current request URL sent by the server, where it is possible.

On the server-side, the URL desired for permanent redirection should be indicated in the special header field “Location”. In this case, the user agent can determine the value of the Location field for automatic forwarding. Historically, for a subsequent request, a user agent could and most likely would change the request method from POST to GET. To avoid changing the request method, we recommend using the 307 status code.

This type of redirection is often used in practice in two cases:

  • When purchasing additional domain names, like when taking into account the most common typos for the site address, variations of the brand name, or relevant high-profile domains.
  • When determining which link to use and display as the default address (for instance, an address without www.).

.htaccess characteristics

The .htaccess file is a hidden configuration file that starts with a dot and is used on Apache web servers. A .htaccess file is located in the directory and contains directives that allow you to influence the server configuration. A .htaccess configuration file can be edited in the file manager using the code editor, via the FTP Protocol, or locally on the computer using a text editor. For some CMS, such as WordPress, you can install special plugins that will automatically configure redirection. For example, to set up permanent forwarding using code 301, you need to add the following text to the .htaccess file:

Redirect 301 /old-URL/ http://www.companydomain.com/new-URL/

Google Officially on 301 Redirects

When to use 301 redirects? According to the instructions of Google Webmaster Tools, 301 redirects should be applied in the following instances:

  • Changing a domain or domain name. If users know your brand and direct traffic is high enough, you will avoid confusion with a new address.
  • Some sections are duplicated at several different URLs, for example, http://example.com/home, http://home.example.com и http://www.example.com. 
  • You are updating an old site or merging two sites. When users go to outdated pages, they must be redirected to the newest version.

In a discussion on Reddit, John Mueller clarifies that when using the 301 redirect chain, it is better to limit yourself to five links for successful indexing by the Google bot.

Reddit

And in this video, John Mueller answers how long it takes to index a page after setting up 301 redirects. He also explained that code 301 is first interpreted as one of the signals for determining the canonical link.

Forwarding is viewed in the context of factors, such as:

  • internal links;
  • a site map file;
  • a set of links to the original page.

The new link will only be considered canonical for indexing if all these factors give enough affirmative signals. Therefore, it is equally important to update the existing links on the site and not only set up redirects. It is also important that you contact the site owner’s with the most important backlinks to ensure that they update the information. The more clearly and unambiguously you point to the new link as the current version, the better. To check to see if everything is in working order, Mueller recommended using the link checking tool in the Search Console.

About WordPress 301 Redirects. Implementing a 301 Redirect in WordPress

How to set up a 301 redirect? When using the WordPress CMS, there are several ways you can configure a 301 redirect. We recommend that you make the appropriate changes to the .htaccess file on your server. Remember to have backups before starting any experiments with .htaccess! To make changes to .htaccess, you need to connect to your site through an FTP client and open the root directory. If the desired  file is not in the root directory:

  • Check whether hidden files are being displayed in the FTP client.
  • The file might not have been generated yet. You can check this quickly by opening the WordPress settings and going to the Permalinks tab. Do not make any changes, just click “Save Changes”. If you do not see any error messages, update the FTP client and that is it! The file should be there.
  • If the file is still missing, other solutions and more detailed instructions can be found here

Then all you have to do is open the .htaccess file and make the necessary changes using any text editor. For convenience and reliability, it is recommended that you add new lines at the end of the file. 

For example:

RewriteEngine On

Redirect 301 /old-version/ http://companysite.com/new-version/

You can also configure 301 redirects using a variety of WordPress plugins, such as Redirection, Yoast, All in One SEO Pack, Rank Math or analogs. You can read how to do this in our article Setting Up Yoast SEO vs. All In One

A Note about 404

John Mueller also tweeted that there are specifics when using 301 and 302 redirects to handle the 404 error code.

Twitter

To use redirect codes to improve the user experience when navigating to non-existent pages, you must first find all the pages that return the 404 status. To do so, open the Coverage section in the Google search Console and go to the 404 section. It is recommended that you do this regularly so that users always go to the current pages without wasting time on standard error pages.

What is a 302 redirect? A Description of the HTTP 302 Status Code

Status code 302 indicates that the target resource has been moved temporarily and is available through a different URL. Because redirects might change in the future, it is recommended that the client continue using the current request URL as the primary URL.

In the first version of HTTP, the 302 status returned the value “Temporarily Moved”, but the current version of the protocol, HTTP 1.1, as described in the RFC 2616 specification, assigned code 302 the value “Found”. Simply put, a 302 redirect is a redirect that informs search engines that the page is moved temporarily, but it may be available at the original address in the future. Unlike with 301, when using 302 redirections the original link’s weight is not passed on. A total of 302 redirects are used to update or maintain sections of the site, or for A/B testing.

The Differences Between 301 and 302 Redirects

There are two main differences between a permanent 301 redirect and a temporary 302 redirect. The Google algorithm tells the link with the set permanent redirect the weight of the original link and also displays the updated address in the search results. Temporary redirects, including 302, do not receive the weight from the source links and the original address will continue to appear in the search results. This is because the redirect specification 302 clearly defines it as a temporary page replacement that will be restored to its original address.

When to Use 302 Redirects

In general, webmasters try not to use a 302 redirect unless necessary. 

But there are a few cases where this redirect will come in handy:

  • A/B testing the functionality or design of web pages;
  • For collecting feedback about a new page from users or customers without affecting the entire site’s ranking;
  • When you are updating a web page or a section of the site that will not impair the user experience while working.

J. Mueller on 302 Redirects

This kind of redirection is often used incorrectly. For example, it is often used as though it is permanent, although this contradicts the specification and purpose of code 302.

In this video, John Mueller talked about how Google will act in such cases. In particular, when the search bot encounters a redirect via the 302 code, it will think that this is a temporary phenomenon, and the original, old, link will remain. But if the bot sees the same direction over and over again, it will assume that an error was made and a permanent redirection was implied. In this case, the 302 redirects will be processed just like a 301, meaning that the final, or new, link address will be displayed in the search results.

Bad Practices of Redirects

Redirecting 404 Links to the Homepage

John Mueller denounces this practice as a manifestation of the laziness of webmasters since the search service still considers these links to be invalid.

Twitter

In this situation, it is necessary to configure a suitable redirect and work on a memorable 404 page to process such requests, offer visitors similar content, and the option of on-site search or other navigation options. Otherwise, sanctions may follow.

Error Redirection for Mobile Page Versions

If a sub-domain is used for the mobile version, you should check if the desktop site matches its mobile equivalent, for instance:

  • A correct redirection is from “companysite/about” to “mobile.companysite/about”;
  • An incorrect redirection is from “companysite/about” to “mobile.companysite”.

The same rule applies to AMP pages, their URL scheme must match their canonical pages. For instance, redirecting from “companysite/about” to “amp.companysite/about” or companysite/amp/about is correct, but not to “optimized.companysite/ourteam”.

For sites that use AMP technology, it is important to remember that when updating the structure or content, it will also take some time to create updated AMP versions of the main pages. However, to ensure that users get to the current version of the AMP page, it is recommended that you configure the corresponding redirects as soon as the main content is updated. For example, from the companysite.com/amp/old page to the companysite.com/amp/new.

If, for example, there is no mobile version of the page, we recommend that you do not redirect it at all to avoid confusion and penalties. This also applies to 404 pages, if there is no desktop version, then the mobile version should also direct to the 404 page. 

You can also configure the redirection of mobile clients to the AMP version of the page if you do not have an adaptive version. Redirects can be made permanent through code 301, or temporary via code 302.

Excessive Redirection

This mistake occurs when the redirect chain becomes a loop. For example, you set up the redirection from one page to another and then forgot about it. After a while, it became necessary to set up a reverse redirection from the second page back to the first. And the result of this is an infinite loop that returns an error message.

Redirecting via Instructions in the Meta Description

Another way to redirect a user from one page to another is to add a similar instruction to the meta-tag:

<meta http-equiv=”refresh” content=”0;url=http://companysite.com/new-URL/” />

Although this is not explicitly prohibited by Google, and John Mueller confirmed that such redirection works, he also noted several drawbacks of this approach.

Twitter

In particular, the users’ experience suffers, and the processing time for HTTP requests increases. This is also true for redirects via JavaScript.

Miscellaneous

The most commons errors when setting up permanent redirection includes: 

  • redirection chains that are too long and unnecessary;
  • using the wrong type of redirection;
  • using internal forwarding without updating the links;
  • redirecting to outdated pages or content;
  • redirecting to pages that do not return a 200 status code.

Examples of Usage and Configuration

from HTTP to HTTPS

Apache 

  • Log in to the Apache server and navigate to the path where it is installed;
  • Open the conf folder and create a backup copy of the httpd.conf file;
  • Open httpd.conf in any editor, such as vi;
  • Make sure that the mod_rewrite.so module is loaded;

LoadModule rewrite_module modules / mod_rewrite.soCopy;

  • If the line above contains comments, delete them;
  • Add the following text to the end of the file;

RewriteEngine On;RewriteCond %{HTTPS} off;RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI};

  • Restart the Apache webserver.

Nginx 

  • Log in to the Nginx webserver;
  • Backup the server directive file (nginx.conf or default.conf);
  • Add the following to the server directive;

return 301 https://$server_name$request_uri;

  • Save the changes and restart the server.

Cloudflare 

  • Log in to Cloudflare and select your site;
  • Go to the SSL/ TLS tab and open the “Edge Certificates” section;
  • Enable the “Always use HTTPS” option.

cPanel 

  • Make sure the hosting provider provides SSL and that the option is enabled for your site;
  • Log into cPanel and open the .htaccess file in the manager;
  • Add the following text to the end of the file;

RewriteEngine On;

RewriteCond %{HTTPS} off;

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI};

  • Save the changes.

SUCURI

  • Go to the HTTPS/SSL tab;
  • Select “Full HTTPS” in SSL mode;

  • Select “HTTPS only site” in the Protocol Redirection settings;

  • Save the changes.

www, / and other

You have to add a new rule to the .htaccess file, this can be done via FTP, SSH, or on the control panel at your discretion. 

Once you find and open the file you need, add the following code:

  • To avoid displaying www in the address (i.e. https://companysite.com)

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.companysite\.com$ [NC]

RewriteRule ^(.*)$ http://companysite.com/$1 [R=301,L]

  • To display www in an address (i.e. https://www.companysite.com)

RewriteEngine On

RewriteCond %{HTTP_HOST} ^companysite\.com$ [NC]

RewriteRule ^(.*)$ http://www.companysite.com/$1 [R=301,L]

  • To avoid using  / at the end of a URL (i.e. https://companysite.com/page )

RewriteCond %{HTTP_HOST} (.*)

RewriteCond %{REQUEST_URI} /$ [NC]

RewriteRule ^(.*)(/)$ $1 [L,R=301]

  • To use / at the end of a URL (i.e. https://companysite.com/page/)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_URI} !(.*)/$

RewriteRule ^(.*[^/])$ $1/ [L,R=301]

  • To remove the extra slashes in the address (i.e. companysite.com///page)

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$

RewriteRule . %1/%2 [R=301,L]

  • To remove extra dashes in the address (i.e. companysite.com/page1)

RewriteCond %{REQUEST_URI} ^(.*)–(.*)$

RewriteRule . %1-%2 [R=301,L]

About author
george-caravan
George is a freelance digital analyst with a business background and over 10 years of experience in different fields: from SMM to SEO and development. He is the founder of Quirk and a member of the Inspiir team, where he is working closely with stakeholders from many popular brands, helping businesses grow and nurturing meaningful projects. George writes regularly on topics including the technical side of SEO, ranking factors, and domain authority.