Htaccess Redirect For Better Pagerank & Other Analytics

.htaccess (hypertext access) redirect is very important to route all the traffic to one form of URL of their blog. It is best to use .htaccess redirect both in the case of humans and bots, as the bots and humans will be handling the URL for various purposes like linkback in case of humans or crawling in case of bots of Google and Microsoft. .htaccess redirect helps in maintaining a single format for your blog or website.

The Different forms of URL can hinder the Pagerank and other analytics, as they would take your blog or website in two different forms and rate it differently. The two most commonly seen formats are with WWW and without WWW , for example ;

The two formats will be differently handled and hence the linkbacks for humans and the URL for Google bots and Microsoft bots will not appear same. The solution for the above problem is to use .htaccess redirect.

Redirection from with www to without www can be achieved by creating a .htaccess file in your control panel root directory, this will usually be in the public_html in cpanel file manager and similarly in other Control panels like Plesk.

To redirect the with www URL to without www URL, edit the .htaccess file and insert the code given below and save:

## Redirect to
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Introduction To HTACCESS

HTACCESS stands for Hypertext Access. It is a directory-level configuration file used on Apache web servers.

By customizing the htaccess file, you can get the most out of your website’s functionality and can improve your search engine rankings through search engine optimization (SEO).


There are two common ways to access your .htaccess file :

1. File Manager : Login to your hosting account to access and modify your files. You can do this by using your web based File Manager.

2. FTP (File Transfer Protocol) : You can access through an FTP client software. I prefer Filezilla.

Browse to the root of your publicly viewable folder. This is mostly named as public_html or www. In this folder only your homepage located.

If you are already familiar with .htaccess, you can try these :

1. How To Create 301 URL Redirection?

How to Create A HTACESS file :

In some cases you won’t have an .htaccess file in that folder. You don’t need to worry for it. Creating a .htaccess is far simple.

1. Open Notepad or any other editor

2. Type the required code

3. Save it with an extension .htaccess

Note :

  • There should be no text before the period. It has to be exactly “.htaccess”.
  • It can also be saved without anything in it. HTACCESS file can also be a blank file.

Correct Permissions :

It is very important that your .htaccess file have the correct permissions for preventing others from modifying the file and take full control of your website/blog.

The permissions should be set at 644, rw-r-r. You can check the permissions by right clicking on the file and choosing permissions or CHMOD with the help of FTP Client Software.

Now you have created your .htaccess file. Watch out some worthy tutorials in upcoming posts to make your blog/website secure !

HOW TO: Create 301 URL Redirection

URL redirection is also called URL forwarding, URL shortener, domain redirection and domain forwarding.

Why to redirect a website?

For Similar Domain Names :

301 RedirectionA user accessing a particular domain name may type the wrong spelling of it. For example, consider and Here one ‘l’ is missing in the second domain name. Organizations often register these mis-spelled and redirect them to the correct domain name. Another example is redirecting domains for reserving TLDs (Top Level Domains). The addresses and could both redirect to a single domain, such as

MUST READ : Introduction To HTACCESS For Newbies

Moving a website to a new domain :

A webpage or website can be redirected for many reasons like the website might need to change its domain name or the author of that website might move his or her pages to a new domain.

HTTP Status codes for redirect :

  • 300 Multiple Choices  (like offering different languages)
  • 301 Moved Permanently
  • 302 Found (like temporary redirect)
  • 303 See Other (For results of CGI-Scripts)
  • 307 Temporary Redirect

Common Methods for Redirecting A Website [URL Redirection]

Open Notepad or any other editor and copy the required code and save it. Then upload that file to your directory. I made use of the PHP redirect for redirecting My Mobile Site to Google Reader. I made mobile version of my blog through Google Reader.

ColdFusion Redirect

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="">

PHP Redirect

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location:" );

ASP Redirect

<%@ Language=VBScript %>
Response.Status="301 Moved Permanently"
Response.AddHeader "Location",""

ASP .NET Redirect

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
Response.Status = "301 Moved Permanently";

JSP (Java) Redirect

response.setHeader( "Location", "" );
response.setHeader( "Connection", "close" );

.htaccess Redirect

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

CGI PERL Redirect

$q = new CGI;
print $q-&amp;gt;redirect(&amp;quot;;quot;);

Ruby on Rails Redirect

def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to ""

HTML Redirect

Place the following HTML code between the <HEAD> and </HEAD> tags of your HTML code.

<meta HTTP-EQUIV="REFRESH" content="0; url=">