August 28 th

2

Code to redirect surfer from a no ‘www’ address

Posted by Andy Bailey
756 views

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.

Popularity: 1% [?]

Category : Code

Related Posts

  • Simple code to reveal asterisk (*’s) password fields in your browser
  • How to make a Wordpress plugin with less than 20 lines of code
  • Another coding frenzy successfully finished
  • Change your Wordpress permalink structure without screwing up your original links
  • And the winner is…. OMG who woulda thunk it?
  • CommentLuv Update by popular demand!
  • My O2 customer service story (with happy ending)

  • Comments

    Busby SEO Challenge (5 comments.) August 2, 2008

    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

    Earth4Energy (1 comments.) August 26, 2008

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

    Leave a comment

    follow fiddyp on twitter

    16 online now
    the most online was 176
    Sponsors
    available ad space available ad space available ad space available ad space available ad space available ad space