Search Engine Optimization using 301 Redirects

Search Engine Optimizations, i am very sure that all would have heard this term by now, in simple terms its a process of "making your website Search Engine friendly" there are various ways methods to do this, let me be very clear there is no specific way by which you can have a perfectly optimized website, in this post i discuss one of the methods by which you can remove the confusion of a search engine :).

Confused Search Engine !!! yes this happens often, just because of a silly mistake done unknowingly. Search engine often gets confused due to the links for example http://www.example.com and http://example.com may open same website but they are 2 different links and hence there are chances that both of them gets listed on search engines which is not what you will want to happen how to solve this problem ?

And i have a one line answer to this "by using 301 redirects" or "URL Redirections" below is the process by which you can implement this on various types of websites

For Websites hosted on Linux Servers

Edit .htaccess present in web root and add the following lines

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

This will redirect requests for example.com to www.example.com ensure you have mod_rewrite enabled.

For Websites hosted on IIS use the following steps

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

Just in case you don't have control on the server as if you are on a shared hosting which does not provide any such service you can also programatically  redirect below are the code for PHP and ASP similar kind of code is applicable for others

For PHP

<?php
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.example.com" );
?>

For ASP

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