How to make a search engine optimisation friendly .htaccess file
A lot of sites can have duplicate content issues and especially CMS (Content Management Systems). I talked about the canonical link element on a previous post, which describes how to let Google know what page holds the original copy within your website.
This post on how to build a search engine optimisation friendly .htaccess file and is designed as a basic piece of good practice in SEO, which helps sites with duplicate content issues and means that links which are not 100% accurate are still rated by Google.
For Example. If you have links going to /index.php and not the root this can be interpreted as 2 different pages, I have seen sites with different Page Ranks on the root/ to the index/ page.
You can stop this happening by adding a .htaccess file or similar dependent on your host / server. The following code is designed for a linux apache server and is designed to revert the following:
- domain.co.uk >> www.domain.co.uk
- www.domain.co.uk/index.php >> www.domain.co.uk
- domain.co.uk/index.php >> www.domain.co.uk
To do this you require 2 sections of code to be added to your .htacess file; The first adds the www. back onto the front of the domain.
So from domain.co.uk >> www.domain.co.uk
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.domain.co.uk/$1 [R,L]
The second removes the index.php;
So from www.domain.co.uk/index.php >> www.domain.co.uk
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.domain.co.uk/$1 [R=301,L]
General good practice within SEO if often overlooked, please add any additional servers code in the comments.





































