Wednesday, November 19, 2008

Redirecting index.html to root directory

For getting optimum page rank we use canonical optimization in which we redirects our websites to www or non www. But there are many other types of canonical optimization one of which includes Redirecting index.html to root directory.

Is it Important?
These days google treats index.html and root directory (/) as different files and gives different Page Ranks to both. Have you notice that? Sometimes it also arises the case of content duplicacy.

Solution;
Just use the following Script for redirecting all index.html to it's respective root directory (/) in .htaccess file;

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.webspaceindia.net/$1 [R=301,L]

* Just replace webspaceindia.net with your domain name

If you want to make www redirection as well with it then use;

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.webspaceindia.net/$1 [R=301,L]

Rewritecond %{http_host} ^webspaceindia.net [nc]
Rewriterule ^(.*)$ http://www.webspaceindia.net/$1 [r=301,nc]

These scripts will help your websites in getting optimum Google Page Rank.

2 comments:

Ovidiu Gabriel said...

Interesting....but where we should put that script?

Mohammad said...

thanks a lot for help on htaccess