Couple of blogs I follow was discussing about URL shorteners and its pros and cons. While I wonder about it, I was thinking why would you need URL shorteners when you can easily use 301 Redirect to create your own and still be search engine friendly and even more have total control of your site.  Some of the url shorteners out there put banner ads or splash ads which I hate , but 301 redirect avoids all that.   Its the most efficient  method for webpage redirection and preserves your page ranking and is search engine friendly.  Its very easy to implement .  The code “301” is interpreted as “moved permanently”.

There are few ways to implement the 301 URL redirection : 

Save one of the code onto a file with appropriate extension and upload it your hosting site .

Redirect using PHP

<?php
Header( “HTTP/1.1 301 Moved Permanently” ); 
Header( “Location: http://www.new-url-location.com” ); 
?> 

Redirect using ASP

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

Redirect using ASP.NET

<script runat=”server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,”http://www.new-url-location.com/”);
}
</script> 

Redirect using JSP

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

Redirect using CGI Perl

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


Ruby on Rails Redirect

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

Redirect by configuring IIS

 

  • 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’