Hello friends, today we are going to discuss the difference between 301 and 302 redirects which is pretty important when it comes to the SEO.
301 Redirect – How and where to use?
301 redirect is a part redirect instruction to Google telling that you permanently wants to point your domain to another domain. For example, let’s assume that you have been called ABCD.com for some reasons you are not using the domain and what that domain could be redirected to ABC.com. You know how to tell Google that you domain ABCD.com should be routed to ABC.com and this can be done through a 310 redirect. Using a 301, Google understands that all the traffic on ABCD.com will now be redirected to ABC.com meaning that even the rankings will be transferred to ABC.com. So essentially whatever powers ABCD.com has will now be transferred to ABC.com. 301 redirects can be done due to the several factors some of which are listed here:
- you want to permanently shutdown one domain
- you have a new domain and wants all the traffic to be redirected from your old mentor that you
- you are merging two sites into one and wants one of the sites to redirect all the traffic the other one
- you have several domains and want all of them to be redirected to your main domain.
How to do 301 Redirect?
The simplest method to Redirect Old domain to New domain is using htaccess redirect. If you have the access to the .htaccess file, you have to add a small code to make it working.
Here is the simple syntax for 301 redirect from an old page to new page:
Redirect 301 /old-page.html http://www.abc.com/new-page/
The above redirect will take the url http://www.abc.com/old-page.html and redirect it to http://www.abc.com/new-page/
Redirect an old domain to a new domain
RewriteEngine on RewriteCond %{HTTP_HOST} ^abc.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.abc.com [NC] RewriteRule ^(.*)$ http://abc.net/$1 [L,R=301,NC]
Redirect an entire site
Redirect 301 / http://abc.com/
Redirect an entire site to a sub folder?
Redirect 301 / http://www.domain.com/subfolder/
Redirect from a non-www to www subdomain
RewriteEngine on RewriteBase / rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Redirect a site to HTTPS from HTTP
RewriteEngine on RewriteCond %{HTTPS} on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Remove an index.html or index.php and redirect to the root?
RewriteEngine On RewriteCond %{THE_REQUEST} /index.php HTTP [NC] RewriteRule (.*)index.php$ /$1 [R=301,L]
302 Redirect and how & where to use?
302 redirect on the other hand, is telling Google that you are temporarily changing the locations. Think of it as you’re going to a summer home and you’re staying there so you want your mail forwarded there for a few months and then you will go back to original home. 302 redirects can be due to the following reasons:
- You are temporarily redirecting website to another site
- your one website is under maintenance and you want to redirect the other side
- you are doing AB testing on your sites and wants temporary redirect for testing purposes
How to use 302 redirects?
To create a 302 temporary redirect in .htaccess, add a syntax:
Redirect /product.php http://www.abc.com/promo.php
Temporarily 302 redirect a directory
Redirect /widgets http://www.abc.com/sub-folder
302 temporary redirect to redirect your entire site to some other site
Redirect / http://www.anotherexample.com/
Both the methods if properly implemented can help you the SEO and also help you avoid the loss of traffic. Please note that 301 and 302 redirects and implemented takes some time before the changes are actually propagated on search engines so plan I had and give one to three weeks for this exercise.