.htaccess Rewrites for Magento Shops
Magento shops have an annoying way of adding /index.php to every URL which has a negative effect on the search engine optimisation as there’s no way of specifying your canonical URL. The default setup doesn’t enable you to have your own mod_rewrites so there’s several steps you have to take:
1. Enable URL Rewrites in Admin
Go to System > Configuration > Web > Search Engines Optimization and switch ‘Use Web Server Rewrites’ to Yes.

2. Modify the root .htaccess
Youcan get to your .htaccess file easily by FTP, or if not you can use a file manager on your hosting account which is what I did using Plesk’s file manager. Once you have it open to edit, you’ll see it’s a long file with a lot of commented text. First, you need to look for the section that looks like this:
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /magento/
Un-comment it and change it to:
RewriteBase /
This will rewite everything to your root directory instead of a Magento directory. As it was originally commented out, it didn’t have any effect.
3. Add Rewrite Code
Finally you need to find the part a bit further down that’s written like this:
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
Underneath the part which says RewriteRule.*index.php[L] add the following lines of code:
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.co.uk/$1 [R=301,L]
RewriteCond %{http_host} ^yourdomain.co.uk [NC]
RewriteRule ^(.*)$ http://www.yourdomain.co.uk/$1 [R=301,NC]
Where ‘yourdomain’ is your domain’s name. That will now remove index.php from the end of the address, as well as turn all non www URLs into www. URLS.
