Before diving in with 301 vs. 302 redirects for modern day SEO, let us encounter the idea of redirection. One website can be reached by several links thanks to the fundamental Internet technique known as redirection. Redirecting HTTP requests is still a rather baffling problem for webmasters and search engines in 2020. Redirection can occur at the domain level and at the link level, where another link opens in place of the original.
If you wish users to be able to access your website using many alternative addresses, for instance: company.com, company.org, and company.us To accomplish this, you can register the required domain names, designate the primary domain name, and set up permanent redirection for the secondary domain names.
Redirects are most frequently used for the following reasons:
an unreliable or absent link;
a fresh webpage or website;
temporary inaccessibility, for instance, you are modifying or restoring a page and you want to redirect users until you are finished working;
a page that has been deactivated or removed, perhaps for older or discontinued products;
changing to a different CMS platform;
You don't want to undermine the value of the link because someone posted a backlink/inbound link to a broken page or one that is not accessible right now;
Changing or upgrading the site's navigation;
slicing a lengthy link;
to prevent broken links caused by page moves;
to link several domains together to form one website;
to link related domain names to the same website, for instance, if you are accounting for the most frequent mistakes;
to safeguard personal data
to stop re-sent POST/ REDIRECT/ GET requests on forms;
to send visitors to regional or mobile versions of the page;
switching to a more secure protocol or putting in place an SSL security certificate, for instance;
in order to conduct A/B testing on various iterations of pages, content, branding, etc.
Hackers frequently employ redirection, for example:
for tricking search engines;
to mislead customers;
to remove referral traffic information;
for deceptive operations like the propagation of malware or phishing.
Read more about SPAM and how to protect yourself in this article.
Redirects can be used for a wide range of functions, as you can see. Knowing the fundamental methods for configuring redirects is crucial for maintaining the ranking and user experience of your pages as choosing the right tool is only half the battle. The most common redirects include these:
Precise Description
If a page or resource has been transferred and will be permanently used at its new location, HTML status codes 301 and 308 are applicable. When redesigning a web page or switching to a safer protocol, a permanent redirection is a fantastic option. RFC 7538, which added the 308 redirect, was published in 2015.
The code has not been supported by all browsers, as with all breakthroughs. For instance, Windows 7 and 8 both come with Internet Explorer 11, yet when error number 308 occurred, it simply displayed an empty page.
The client's response determines how redirects 301 and 308 are handled differently (the browser). In particular, the client must resubmit the identical request on the redirected page if they receive a 308 HTML status code. To put it another way, if you send a POST request and receive a 308 redirect in the response, your browser will need to send a POST request to the website you were sent to. A 301 HTML status code enables you to redirect when changing the request method, which is typically the case with clients.
To maintain greater compatibility, it is generally advised to stick with 301 code for ongoing redirects. However, you can utilise the 308 redirect if you are confident that all of your customers will be able to correctly comprehend the updated code and if the handling of POST requests is crucial.
The 302 status code for temporary redirects was the sole one specified in the 1996 release of the HTTP/1.0 protocol.
Despite it being stated that clients cannot alter the request method in a redirected request, the majority of browsers always perform GET on the redirect URL. This is the primary justification behind the adoption of the new status codes 303 redirect and 307 redirect in the 1999 update to HTTP/1.1. Temporary redirect codes let users know that a page or resource they're interested in is actually available at a different address. This means that the end date of temporary redirection limits their lifespan and that content caching is not necessary. For instance, the best course of action is to set up a temporary redirect to the correct landing page if one of your pages needs technical work. For submitting alternative versions of the content or complete sites based on location, device, or other particulars of each user, temporary redirects are also advised.
Regardless of the approach that was initially used, the HTTP 303 status code informs the client that the resource is momentarily available somewhere else and it expressly directs the user to conduct a GET request for the new URL. The client is instructed to retry the request with a different URL and the same request method as they used for the initial request with the status code 307.
Redirects are always carried out as GET requests since, in practise, browsers and search bots interpret code 302 the same way they do code 303.
Despite the passage of sufficient time since the submission of status codes 303 and 307 in 1999, some clients continue to transgress the norm and fail to complete requests in accordance with its specifications. As a result, for compatibility concerns, much as the situation with codes 301 and 308, we generally advise following the 302 redirect.
The Influence on Search Engine Optimization
The outdated version of the page is substituted for the original one when a Google search bot detects permanent redirection 301 or 308. It makes sense to wonder if this has an impact on the page's ranking weight. In this video, Matt Cutts explains how employing 301 redirects results in about the same amount of link weight loss as a regular link. Additionally, Matt Cutts addresses in this video if a site or page can have a certain number of permanent redirect codes. Therefore, you do not need to be concerned about persistent redirects harming your SERP ranking.
Temporary redirections are merely aesthetic from Google's perspective. The search engine is aware that HTTP codes 302, 303, and 307 are transient since they are partially disregarded.
The original page doesn't change, the ranking factors don't alter, and not even a little amount of the weight from the original page is transmitted to the temporary links.
Another thing to think about when utilising HTTP redirects is how they may affect performance.
Every redirect adds a few hundredths of a millisecond to the loading time of your page since it requires another HTTP request. While a single redirect is harmless, you should avoid having lengthy redirect chains to prevent user experience degradation and, if at all feasible, lessen the burden on the web server.
The HTTP 301 status code indicates that the target resource has a new permanent URL and that any future links to this resource should use the new suggested URLs. Where possible, the link editing clients should update the data on their own to reflect the most recent URL that the server has sent.
On the server, the URL that you want to permanently redirect traffic to should be listed in the "Location" header field. In this scenario, the user agent can choose the Location field's value for automated forwarding. In the past, a user agent may and most likely would switch the request method from POST to GET for a later request. Using the 307 status code is advised to prevent changing the request method.
In two scenarios, this kind of redirection is often used:
When purchasing extra domain names, such as when considering the brand name variations, pertinent high-profile domains, or the most frequent misspellings of the site address.
Choosing the link to utilise and show as the default address (for instance, an address without www.).
On Apache web servers, there is a hidden configuration file called .htaccess that begins with a dot. The directory contains a .htaccess file, which has directives you can use to modify the server settings. The code editor in the file manager, the FTP Protocol, or a text editor installed locally on the computer can all be used to edit .htaccess configuration files.
You can set up specialised plugins that can automatically configure redirection for various CMS, like WordPress. For instance, you must include the following line in the.htaccess file to configure permanent forwarding with code 301:
Redirect 301 /old-URL/ http://www.thedomainofcompany.com/new-URL/
301 Redirects and Google Officially
When do 301 redirects get used? The following situations call for the use of 301 redirects, according Google Webmaster Tools' instructions:
Altering a domain name or domain. Users who are familiar with your brand and who visit your website frequently will not be confused by a new address.
Several URLs, such as http://example.com/home, http://home.example.com, and http://www.example.com, repeat certain aspects.
You are combining two sites or replacing an outdated one. Users who access out-of-date pages must be routed to the most recent version.
John Mueller clarifies that employing the 301 redirect chain should be limited to five links for the Google bot to successfully index your site in a Reddit debate.
John Mueller also addresses how long it takes for a page to index once 301 redirects are set up in this video. The canonical link is identified by first interpreting code 301 as one of the signals, he added.
When considering forwarding, consider the following factors:
internal links;
sitemap file;
a set of links leading to the source page.
If enough positive signals are provided by all of these variables, the new link will only be accepted as canonical for indexing purposes. As a result, updating the site's current links is just as crucial as setting new redirects. Additionally, it's critical to get in touch with the website owners of the most relevant backlinks to ask them to update their content. The updated link should be identified as the most up-to-date version with as much clarity and unmistakability as possible. Mueller suggested using the Search Console's link checking tool to make sure everything is operational.
How do you set up a 301 redirect? When utilising the WordPress CMS, there are numerous ways to set up a 301 redirect. You are urged to make the appropriate changes to your server's .htaccess file. Have backups on hand before undertaking any .htaccess tests! To edit .htaccess, you must connect to your website using an FTP programme and open the root directory. In the event that the desired file is not in the root directory:
To see if hidden files are displayed, check the FTP client.
The file might not have been produced yet. You may do this by simply opening the Permalinks tab in the WordPress settings and clicking this box. Without changing anything, click "Save Changes." If no error messages appear, simply update the FTP client. The file should be available.
If the file is still missing, you can find more patches and more detailed instructions here.
All that is left to be done is to open the.htaccess file in any text editor and make the necessary changes. For reliability and convenience of use, it is recommended that you add new lines at the end of the file. Consider this:
RewriteEngine On
Redirect 301 /old-version/ http://siteofcompany.com/new-version/
A number of WordPress plugins, including Redirection, Yoast, All in One SEO Pack, Rank Math, and analogues, can be used to set up 301 redirects. Our post, Setting Up Yoast SEO vs. All In One, explains how to achieve this.
Note regarding 404
Additionally, John Mueller stated that there are guidelines for handling the 404 error code using 301 and 302 redirection.
You must first identify all the pages that return the 404 result before you can utilise redirect codes to enhance the user experience when navigating to non-existent pages. To do this, go to the 404 area under Coverage in the Google search Console. It is advised that you carry this this routinely so that consumers always land on the most recent pages and don't waste time on default error pages.
Describe a 302 redirect: A Definition of the HTTP 302 Status Code
The HTTP 302 status code signifies that the target resource has temporarily migrated and is now accessible via a different URL. It is advised that the client keep using the current request URL as the primary URL because redirection could change in the future.
In the initial implementation of HTTP, the 302 status code returned the value "Temporarily Moved," however in HTTP 1.1, as specified in the RFC 2616 specification, code 302 now returns the value "Found." A 302 redirect, to put it simply, is a redirect that tells search engines that a page has temporarily been moved but may one day be accessible at the original location.
The weight of the original link is not transferred when employing 302 redirects, in contrast to 301. 302 redirects in total are used for A/B testing, site maintenance, and updating.
The Distinctive Characteristics of 301 and 302 Redirects
A permanent 301 redirect and a temporary 302 redirect differ primarily in two ways. The Google algorithm displays the updated location in the search results as well as the weight of the original link for links with specified permanent redirects. The original location will continue to show up in the search results even though temporary redirection, such as 302, do not receive the weight from the source links. This is so that it is evident from the redirect specification 302 that it is only a temporary page replacement before returning to the original location.
Utilizing 302 Redirects: The "When" question.
Webmasters often strive to avoid using a 302 redirect unless absolutely required.
However, there are a few situations where this redirect will be useful:
web page design or functionality A/B testing;
for gathering user or customer comments on a new page without affecting the ranking of the entire site;
when you are working on changing a web page or a piece of the site without degrading the user experience.
302 Redirects: J. Mueller
This type of redirection is frequently applied inadvertently. For instance, it is sometimes utilised as if it were permanent, which is against the intent and intent of code 302.
In this video, John Mueller discussed Google's approach to similar situations. The previous, original link will still exist when the search bot sees a redirect via the 302 code since it will assume that this is a transient phenomena. However, if the bot notices the same direction repeatedly, it will believe that a mistake was made and that a permanent redirection was intended. The new, or final, link URL will be displayed in the search results in this instance since 302 redirects will be processed similarly to 301 redirects.
Redirects Done Wrong
Homepage getting linked to 404 error pages
John Mueller criticises this strategy as an example of webmasters' laziness because the search engine still considers these links to be illegitimate.
Setting an appropriate redirect and working on a memorable 404 page are necessary to manage such requests, offer visitors similar content, and give them the option of using the site search or other navigation choices. Alternative sanctions may be imposed.
Redirection of Errors for Mobile Pages
The desktop site should mirror its mobile equivalent if a sub-domain is utilised for the mobile version. For example:
A correct redirection form is from “companysite/about” to “mobile.companysite/about”;
whilst
An incorrect redirection form is from “companysite/about” to “mobile.companysite”.
AMP pages must adhere to the same norm as their canonical pages in terms of their URL structure. For instance, redirecting from “companysite/about” to “amp.companysite/about” or companysite/amp/about is the right way but not to “optimized.companysite/ourteam”.
It's crucial to keep in mind that AMP versions of the main pages will take some time to develop for sites that employ the technology when upgrading the structure or content. However, it is advised that you set up the relevant redirects as soon as the primary content is updated to guarantee that people reach the most recent version of the AMP page. For instance, from the companysite.com/amp/old page to the companysite.com/amp/new.
For instance, if the page does not have a mobile version, we advise not redirecting it at all to prevent confusion and fines. In the case of 404 pages, the mobile version should also link to the 404 page if there isn't a desktop version.
If you do not have an adapted version, you can configure redirecting mobile clients to the AMP version of the page. Codes 301 and 302 can be used to make redirects permanent or temporary, respectively.
Excessive Redirection
This error happens when the redirection chain loops. For instance, you might have put up the page redirection and then forgotten about it. A reverse redirection from the second page back to the first has to be put up after a while. As a result, an error message is returned by an infinite loop.
Redirecting using the Meta Description's Instructions
Including a similar directive in the meta-tag is another technique to reroute visitors from one website to another:
Although John Mueller acknowledged that such redirection works and this is not expressly forbidden by Google, he also pointed out a number of disadvantages of this strategy.
The user experience is particularly compromised, and HTTP request processing times lengthen. The same is true for JavaScript redirection.
Miscellaneous
The most frequent mistakes made when configuring permanent redirection include:
extensive and needless redirection chains;
utilising the incorrect redirection method;
internal forwarding whilst the links are not updated;
sending users to stale pages or content;
sending users to pages that don't have a 200 response code.
Examples of Configuration and Use
Apache
Navigate to the directory where it is installed by logging into the Apache server;
Create a backup copy of the httpd.conf file by opening the conf folder;
Launching vi or any other editor to view httpd.conf;
The mod rewrite.so module must be loaded;
Mod rewrite.soCopy; LoadModule rewrite module;
Remove any comments from the line above;
the following words to the file's end;
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
Verify that the hosting company offers SSL and that your website has the option activated.
Open the .htaccess file in the manager after logging into cPanel;
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 HTTPS/SSL tab;
Then select “Full HTTPS” in SSL mode;
Select “HTTPS only site” in Protocol Redirection settings;
Save the changes.
www, / and other
A new rule needs to be added to the.htaccess file; you can do this however you like, using FTP, SSH, or the control panel.
When you've located and opened the required file, 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/page—1)
RewriteCond %{REQUEST_URI} ^(.*)–(.*)$
RewriteRule. %1-%2 [R=301,L]
Ayushi Mishra is a content writer and proofreader with a flair to juggle between writing and the vision of curating unmatched content
More Posts By This author
Write a comments