logo Lee Johnson SEO

www. to non www htaccess re-write rule

Get rid of the multiple versions of your home page by adding this to your htaccess file. Remember to change domain.co.uk with your domain and TLD.

# www. to non www
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^(([^./]+/)*[^./]+)$ /$1/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www.domain.co.uk [NC]
RewriteRule ^(.*)$ http://domain.co.uk/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^.*/index.*
RewriteRule ^(.*)index.*$ http://domain.co.uk [R=301,L]
</IfModule>