Code to redirect surfer from a no 'www' address

August
28

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.

Code


0 Comments zu “Code to redirect surfer from a no 'www' address”

  1. Busby SEO Challenge
    02.08.08 10:04 pm

    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

    #1

  2. Earth4Energy
    26.08.08 11:04 am

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

    #2