MOD re-write function for Apache PHP Servers - SEO friendly URLs
Friday, July 10th, 2009
Nick and James explain the benefits of using a .htaccess file and Mod Re-writes to generate SEO friendly URLs.
.htaccess code:
RewriteEngineOn
RewriteCond %{HTTP HOST}!^www.domain.co.uk$[NC]
RewriteRule^(.*)$http://www.domain.co.uk/$1[R,L]
Options+FollowSymLinks
RewriteCond %{THE REQUEST}^.*/index.php
RewriteRule^(.*)index.php$http://www.domain.co.uk/$1[R=301,L]
Other .htacess commands for Apache PHP servers:
http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html
Script:
Nick: Hi and welcome to our SEO video blog, we’re Nick and James from the Creare group.
To day we are going to go through the Mod Re-write function for Apache PHP servers and how to create SEO friendly URL’s.
James: So this is how you want your domain to display:
http://www.domain.co.uk/
There are variations that can get cached by the search engine bots for example:
http://domain.co.uk
http://www.domain.co.uk/index.php
Nick: So we do this to stop the search engines treating the same content as the 2 different pages. I have seen index pages and defaults pages that have picked up different PR (Page Ranks) to the root directory. This isn’t good practice and it also mean that any incoming links are re-directed back to the root directory.
James: So in order to use the Mod Re-Write settings, you need to ensure that your server has mod re-write enabled. We use one and one and fasthosts, both their re-seller packages and dedicated servers which are supported on their.
What you have to do to use the mod re-write settings is to create a .htaccess file, which is uploaded to the remote view.
Nick: There are 2 write conditions, the first re-directs back to www.domain.co.uk/ and the other re-directs away from /index.php.
I will show you a quick example of this now on Creare Communications. If we have a look at creare communications and remove the www. press enter we can see that it re-directs back to www.crearecommunications.co.uk and if we add index.php on the end it also re-directs back to the root.
James: Thanks Nick, the code that we used for that example is available on the blog post and can be copied and posted.




