Implementing a 301 and 302 redirects

301 and 302 redirects

Many people sometimes, mistake a 301 HTTP status code for a 302. While the former talks about permanent redirect, the latter talks about temporary redirect. If you want to either change from one domain name to another, or change from HTTP to HTTPS, basically anything change that will require driving your subscribers or traffic from point A to point B, hence a redirect is the best implementation. Also, you can redirect from a WWW version to a non-WWW version or vice-versa. Redirects are very important because they help fix issues of duplicate contents.

For instance, if you type giwarufus.blogspot.com.ng in your browser, you will be redirected to www.rupheezy.com.ng because a 301 redirect was implemented.

When it comes to SEO, it is very important to know that a 301 (permanent) or 302 (temporarily) redirect can have a positive or negative effect on your site ranking in SERPs depending on how they are implemented. If you want to move from one domain to another and you are perfectly sure you don't intend on coming back to the old domain, a 301 redirect is the best option to implement so that all traffic values and domain authority ranking will be moved to the new domain. This also goes for a 302 redirect, when you implement this command, all values and ranking still goes to the old domain name because you still have intention of going back to that domain name. In otherwords, if you visit the new domain via a temporary redirect, the traffic and session will still count for the old one.

Implementing a redirect is very much important to crawlers, when you make life easy for crawlers, they in return serve your page to people with ease. This can be done in your htaccess file. If you don't have an htaccess file, you can embed a snippet of code in the head section of your website pages. The .htaccess file is located on your server. Should you not find the file, you can contact your host provider to you can get access to the file. Also, you should be very careful when editing this file because it can affect the overall visibility of your site if wrongly implemented.

How to Implement a Redirect

Depending on the programming language used to develop your website, here are some code you can implement to implement a redirect

PHP Permanent and Temporary Redirect

<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http(s)://www.new-domain-name.domain-extension” );
?>

<?
Header( “HTTP/1.1 302 Moved Temporarily” );
Header( “Location: http(s)://www.new-domain-name.domain-extension” );
?>

ASP Permanent and Temporary Redirect

<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http(s)://www.new-domain-name.domain-extension
%>

<%@ Language=VBScript %>
<%
Response.Status=”302 Moved Temporarily”
Response.AddHeader “Location”,”http(s)://www.new-domain-name.domain-extension
%>

Java (JSP) Permanent and Temporary Redirect

<%
response.setStatus(301);
response.setHeader( “Location”, “http(s)://www.new-domain-name.domain-extension” );
response.setHeader( “Connection”, “close” );
%>

<%
response.setStatus(302);
response.setHeader( “Location”, “http(s)://www.new-domain-name.domain-extension” );
response.setHeader( “Connection”, “close” );
%>

Comments

Post a Comment

Popular posts from this blog

13 Best SEO Tips: Practical SEO Techniques that Work

Infinix Zero 4 Plus: Reviews Specs & Price in Nigeria

SEO Keywords Research: Beginner's Guide (Keyword Analysis)