PR 3 with "www" and PR 0 without "www"

Discussion in 'Site & Server Administration' started by alfaresy, Apr 23, 2007.

  1. eddy2099

    eddy2099 Peon

    Messages:
    8,028
    Likes Received:
    568
    Best Answers:
    0
    Trophy Points:
    0
    #21

    If you are referring to the .htaccess file, you create that as a separate text file, name it as '.htaccess' and upload to your /public_html folder. Only one file per site is all that is needed.
     
    eddy2099, Apr 29, 2007 IP
  2. ahelpinghand

    ahelpinghand Guest

    Best Answers:
    0
    #22
    I'm talking about php header function.
    I checked the pages of my site with and without www, I've found out that both versions have the same PR. It's only different with the home page as without www it has PR 3 and with WWW it has PR 2.
    I have searched the internet and put this in my home page:
    <?php
    if (substr($_SERVER['HTTP_HOST'],0,3) != 'www')
    {
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.PutYourSiteHere.com/');
    }
    ?>

    I'm thinking to put this code a php file and include it in the beginning of all my pages:
    <?php
    if (substr($_SERVER['HTTP_HOST'],0,3) != 'www')
    {
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
    }
    ?>

    This should redirect all the non www to the www version of the same page, so I could combine the PageRank and stop the search engines from thinking that I have duplicate content.
    What do you think?
     
    ahelpinghand, Apr 29, 2007 IP