Creating a www. Redirect

May 13th, 2014
Tutorials

I was asked today how to create a redirect on a website so visitors of that site who accessed it with the non www. address got redirected automatically to the www. version. The reason, in this particular case, was to improve the SEO of the website.

So, in this instance, we had the website accessible at:

  • http://websiteaddress.co.uk
  • http://www.websiteaddress.co.uk

And the issue with this set-up was that it was possible the content was being seen as a duplicate (because, technically – it’s two separate addresses) also, when users were sharing the content on social networks like Facebook and Google Plus the counters weren’t adding up correctly. This was because i.e 30 people had shared http://websiteaddress.co.uk whereas 200 people had shared http://www.websiteaddress.co.uk .

Setting up a non www. redirect

To solve this issue you can set-up a redirect in your .htaccess file. For our hosting customers you’d need to access your website via FTP and get the file from your “public_html” folder (the root folder). If you don’t have a .htaccess file there you can create one from scratch, just open a .txt editor and save it as .htaccess (without any file extension at the end).

Once you’ve found/created your file you just want this snippet of code there:

.htaccess file

And that’s it! You’ll now get redirected to http://www.websiteaddress.co.uk if you visited http://websiteaddress.co.uk

About the Author

Charlie Street

An entrepreneur at heart, Charlie is the original founder of Media Street and based at the core of everything it does.

Loading Facebook Comments ...