How to Implement 301 Redirect?

How to Implement 301 Redirect_
Spread the love

How to Implement 301 Redirect?

301 redirect is the most common need for basic search engine optimization nowadays. The most efficient way of redirecting a web page is 301 redirect. It’s not that hard to implement 301 redirects. Let’s learn about how to implement 301 Redirect? It’s the safest option to maintain your rankings on Search Engines if you moved/renames your website pages OR domain name. “301 Redirect” is interpreted as “Moved Permanently”.

As I said, 301 redirect is not a hard job to implement. You can do it easily but yes, it’s important to know which technology your website is developed. There are several technologies OR we can say programming languages available in the market like ASP, PHP, Coldfusion, HTML etc… So you should know that first.

Now, what to do after that? Nothing!!!! Really?? Yeah!

Lol. You must be surprised but I mean what I said.

Let me make it very simple for you to learn how to implement 301 Redirect?. Below I’m giving a collection of all the 301 redirection setup codes for all the technologies/programming languages. So just pick the code from below based on your website technology and implement it on your website and you’re done.

PHP Redirect

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );

Redirect Old domain to New domain (htaccess redirect)

Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain. The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Please REPLACE www.newdomain.com in the above code with your actual domain name.

In addition to the redirect, I would suggest that you contact every backlinking site to modify their backlink to point to your new website.

Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite module enabled.

IIS Redirect

  • In internet services manager, right click on the file or folder you wish to redirect
  • Select the radio titled “a redirection to a URL”.
  • Enter the redirection page
  • Check “The exact URL entered above” and the “A permanent redirection for this resource”
  • Click on ‘Apply’

ColdFusion Redirect

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">

ASP Redirect

<%@ Language=VBScript
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>

ASP .NET Redirect


private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}

JSP (Java) Redirect

<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>

CGI PERL Redirect

$q = new CGI;
print $q->redirect("http://www.new-url.com/");

Ruby on Rails Redirect

def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end


Spread the love

Posted on April 20, 2018 in Search Engine Optimization

Meet The Author

Jobin John
Jobin is a digital marketing professional with over 10 years of experience in the industry. He has a passion for driving business growth in the online realm. With an extensive background spanning SEO, web design, PPC campaigns, and social media marketing, Jobin masterfully crafts strategies that resonate with target audiences and achieve measurable outcomes.
Back to Top
Top