Code to redirect surfer from a no 'www' address

This bit of code sends everyone to the same address whatever they used (http://fiddyp.co.uk goes to http://www.fiddyp.co.uk, also redirects .com addresses to the .co.uk one)



if ($_SERVER["HTTP_HOST"] != "www.fiddyp.co.uk") {

  header("Location: http://www.fiddyp.co.uk");

pretty sweet little function, put it in your header and google wont think www.you.com is different from you.com and penalize you for having duplicate content.

About Andy

This is my personal website where I (occasionally) post about things going on in the world of me. I am the creator of CommentLuv and administrator of comluv.com
Code

0 responses to Code to redirect surfer from a no 'www' address


  1. I would have thought a 301 redirect would have made more sense in this regard especially since that option is more search engine friendly.

    Busby SEO Challenges last blog post..Website Hosting Options

  2. I was facing problem in redirecting for last 3-4 days…. i am thankfull to you that your code works…