Top

Skip links

  • Skip to primary navigation
  • Skip to content

Call us on: 01706 310880

SEO Growth Agency - Valen Digital

Digital Marketing & Growth SEO Agency based in Rochdale, Greater Manchester

  • Home
  • What We Do
    • SEO
    • Content Creation
    • Responsive Web Design
    • PPC (Pay Per Click)
  • Blog
  • Contact
You are here: Home » Our Blog » Redirect non-www to www

Redirect non-www to www

Last Updated: 24th August 2021

non-www to www 301 redirects

When it comes to optimising your website, duplicate content is always an issue but much overlooked. Many webmasters do not even realise that Google may be looking at 2 versions of there home page. The non-www to www versions, and inadvertently be hit by the duplicate content penalty!

That’s because you need to redirect non-www to www version (or visa versa) then Google won’t see 2 versions of your URL and you can be safe from a duplicate content penalty on to your site.

The code below will help get rid of this. It will redirect the non-www to www version of your website via a friendly 301 redirect (technical SEO) telling Google that the site permanently exists at the www version. Of Course this also applies to the rest of the URLs on your site which this code will also fix.

Simply replace example.com with your site reference (highlighted in orange) and the save code to your .htaccess file and upload it to the root folder of your website. If you don’t have a .htaccess file then simply paste the code to a text file and save it as .htaccess then upload to the root of your folder. Your UK Web Hosting account needs to be an based on an Apache server for this to work correctly or a server of a similar type.

PHP
1
2
3
4
5
6
7
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.co.uk [NC]
RewriteRule ^(.*)$ http://www.example.co.uk/$1 [L,R=301]
 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html
RewriteRule ^index\.html$ http://www.example.co.uk/ [R=301,L]

The last 2 lines of code above simply redirect your index file to the root and apply’s a / so that Google doesn’t cache 2 copy’s of your home page i.e. www.example.co.uk and www.example.co.uk/index.html.

You can replace the html part of the code for php or htm if that’s what your using on you site.

UPDATE: Since this original post search engines have started to giv a huge emphasis on sites which use SSL to those that dont.

We have a detailed guide on how you can migrate from http to https which can be combined with the above code to have 1 ultimate variation of your site.

0 Comments

About Amir Farid

Amir Farid is a #TechnicalSEO geek, WordPress enthusiast #WPDeveloper based in Rochdale. He regularly talks and provides online digital marketing solutions to SME's and start-up businesses. Brands he has helped with include Umbrella Host, SEO Umbrella and of course Valen Digital. You Can find him on LinkedIn

guest
guest
0 Comments
Inline Feedbacks
View all comments

Follow Us!

  • Valen Digital on Facebook
  • Valen Digital on Instagram
  • Valen Digital on Pinterest
  • Valen Digital on Twitter

Visit our social media channels for hints, tips and marketing tricks ;)


We are Experts in World Class Technologies Such As:

Experts in CSS3
Experts in HTML5
Experts in Magento
Experts in Wordpress
Experts in Javascript & Jquery
Experts in PHP

  • SEO Rochdale
  • Content Creation
  • PPC
  • Web Design Rochdale
  • About
  • Web Design Services
    • Web Design Rochdale
    • Web Design Manchester
    • Web Design Bolton
    • Web Design Bury
  • SEO Services
    • SEO Rochdale
    • Immigration Lawyer SEO
    • SEO Manchester
    • SEO Bolton
    • SEO Bury
    • Debt Services SEO
  • Page Speed Services
    • Page Speed Optimisation Company
    • Page Speed Optimisation Manchester
    • Page Speed Optimisation Rochdale
Valen Digital Footer Logo

Call Us Today
01706 310880

All rights reserved | Prices exclude VAT @ 20% unless specifically stated.

Copyright © 2010 - 2022 Umbrella Interactive Ltd | Valen Digital is a trading name of Umbrella Interactive Ltd.

Handcrafted with by Valen Digital 15 Water St, Rochdale, Greater Manchester, OL16 1TL | 01706 310880.

Privacy | Cookies | Terms | Directions