Forcing non-www to www with htaccess
Some search engines see https://www.thetwopercent.co.uk and https://www.thetwopercent.co.uk as two separate sites, and more importantly, some web hosts don’t properly direct the non-www version of your domain name – leaving your domain name seemingly unavailable when someone forgets to type in the “www.” before your domain. This is one of my biggest pet hates, and I see it all the time with inexperienced webmasters.
You can solve it simply, by whacking this in a .htaccess file on your server.
# Redirect non-www to www (from https://www.thetwopercent.co.uk) Options +FollowSymLinks # turn mod_rewrite on RewriteEngine On # If http send to http://www. RewriteCond %{HTTP_HOST} ^YOURDOMAIN.COM$ [NC] RewriteRule ^(.*)$ http://www.YOURDOMAIN.COM/$1 [R=301,L]
Replace out YOURDOMAIN.COM with, funnily enough, your domain name in lower case.
Stick this .htaccess in your root directory and you are good to go.