Skip navigation ]

Consolidate your pagerank with .htaccess

Wednesday, February 21, 2007

If you look in the search engines, you may notice that some of the links to your site start with 'www' and others don't. The problem with this canonicalisation issue (despite the situation improving as the search engines become more sophisticated) is that some search engines will view this as two different domains and firstly, will split pagerank between the two and secondly, could push your pages into the supplemental results so your site won't be as easily found.

There is a simple solution to this if you use linux-based hosting and involves editing your .htaccess file. If you don't already have one of these files in the root directory of your hosting server, you'll have to create one. Note that whether you see this file may depend on your FTP program - set it to show all files including hidden ones. I use FileZilla which is an excellent open source FTP program and very simple to use.

The dot (period) in front of the htaccess means that it is a hidden system file. To create an htaccess file, open notepad and save a new file. Ignore the extension which is set to text file (*.txt) and in the filename box type ".htaccess", including the quote marks. You should now have a correctly named file.

Now type in:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.co.uk/$1 [L,R=301]

At the end of the last line, press the enter key to add a newline to the file. This is really important or your htaccess won't work. Now save this and upload it to the root of your website. Some hosts take a short amount of time to update htaccess (GoDaddy for example) but it should work instantaneously on most hosts. This can be adapted for any domain:

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

Just remember to change 'yourdomain' to your actual domain name!

Labels: , ,

Signed by Emma

Get paid to review my blog post

Subscribe to RSS feed Subscribe | By e-mail

Links

Car Tracking
Permanent PR4-PR3-PR2 site submissions for webmasters