Hello all.
I've noticed on the search engines and on my stats that some vistors see my site with www. and some without
David, Would you be able to advise how I only get my site searched for by www.
Will this cause any issues for the current links without www?
Cheers
Mally
Hi Mally,
Always configure my sites so that example.com redirects to www.example.com, for any URL. For example, if you click on the following link:
http://webpricecheck.co.uk/product/iPod-Boombox.html
...you are redirected to the "www" version of the page.
I actually do this within the Apache configuration as a separate virtual host; using something like:
ServerName webpricecheck.co.uk:80
Redirect 301 / http://www.webpricecheck.co.uk/
...however, you can do a similar thing in .htaccess if you do not have access to the Apache configuration and your site is configured to server the same pages with or without www:
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
(put this right at the top, after the RewriteBase line)
With regards to the current links, a 301 redirect means "Moved Permanently"; so the next time a search engine tries one of the non-www links it will update the database to contain only the new link. In the mean time, you will still get all the traffic for the old links as the redirect will do its job!
Cheers,
David.