How to do 301 redirects in Apache htaccess, IIS, PHP, ASP and ColdFusion
Establish proper search-friendly 301 redirects to manage duplicate content issues and changes to your site's information architecture (URL structure) with the specific instructions for your server software below:
Apache Web Server .htaccess file
Apache .htaccess files let you override the Web server configuration on a per-directory hierarchial basis, and are instrumental in the creation of proper 301 redirects. For more information, consult the _Apache .htaccess Tutorial
Canonical Hostname Redirect (non-www to www):
This solution will redirect any page requested via a non-www domain to the same URL with the www domain, and as such it can be placed in the Document Root of your site and will be enforced globally:
Microsoft IIS Web Server
Note: these instructions require administrative access to IIS. If you do not have this access (e.g., if you have a shared hosting account on a Windows server), you should use one of the server-side scripting methods such as ASP or PHP given further below.
1. Open Internet Services Manager and right-click on the file or folder you wish to redirect.
2. Select the radio button "a redirection to a URL".
3. Enter the desitnation page for the redirect.
4. Check "The exact url entered above" and the "A permanent redirection for this resource".
5. Hit "Apply".
Active Server Pages (ASP)
Canonical Hostname Redirect (non-www to www):
This code should be inserted into a global include file or any ASP script which is executed for every page on the site before the page output begins:
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www."
& Request.ServerVariables("HTTP_HOST")
& Request.ServerVariables("REQUEST_URI")
If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
Still Facing difficulties: Contact SEO India Company, Profit By Search.
Profit By Search has been Managing my website’s Pay-Per-Click campaigns on all the Paid Networks like Google Adwords, Yahoo Search ...

+1-646-217-4668
+44-208-123-2466
+91-989-914-9979
+61-280-050-506

