Results 1 to 6 of 6

Thread: Permanent Redirect of "www"?

  1. #1
    Senior Member
    Join Date
    Mar 2004
    Location
    California
    Posts
    724

    Default Permanent Redirect of "www"?

    My customer evidently ran his site through one of those "improve your page rank" analyzers, and came back with this:

    I was looking for ways to improve my page ranking and got this item:

    "Permanent Redirect Not Found

    Search engines may think www.yourdomain.com and yourdomain.com are
    two different sites.You should set up a permanent redirect (technically
    called a "301 redirect") between these sites. Once you do that, you will
    get full search engine credit for your work on these sites."
    I have never had to do this, and thought we were set up that way by default (and I find it odd that a search engine wouldn't be able to figure it out anyway).

    What do you think about this? And, how do I do this ... in .htaccess like I would do any redirect?

  2. #2
    Senior Member
    Join Date
    Mar 2004
    Posts
    140

    Default

    As with everything regarding search engines, nobody has a definite answer but for those inside. What is certain is that search engines do not like duplicated content - i.e. the same content under different URLs. Well, one would suppose that they've already learned that example.com and www.example.com are just the same and not duplicated, but they don't tell. As all this costs you nothing, you may as well play it safe and do the redirect.

    To force a www in front of your domain name drop these lines into .htaccess:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    The inverse is possible too:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
    RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

  3. #3
    Senior Member
    Join Date
    Mar 2004
    Location
    California
    Posts
    724

    Default

    Thanks for the code; I'll bet it isn't necessary, but I went ahead and edited the .htaccess file to include it, and it works (you can check what the headers return on several sites, so I checked using http://news.stepforth.com/seo-tools/...er-checker.php)

  4. #4
    Senior Member
    Join Date
    Mar 2004
    Posts
    140

    Default

    And just when I was almost sure the matter was settled and closed this stuff sneaked up on me from behind, speaking softly and carrying a big cluebat:
    http://www.rooftopsolutions.nl/article/224 (Search engines to support 'canonical urls')

  5. #5
    Senior Member
    Join Date
    Mar 2004
    Location
    California
    Posts
    724

    Default

    Not sure that helps much ... for static html sites, you have to include the directive in every page in the head section? The .htaccess redirect you gave is obviously a better way to do it regardless of what content you have now or add in the future.

    Sometimes I wonder if Google is taking too many pages from Microsoft with creating their own standards.

  6. #6
    Member
    Join Date
    Jul 2008
    Location
    South Shore, Lake Superior
    Posts
    42

    Default I know this is old but..

    This is what I have been using for a long time:

    .htaccess
    RewriteEngine On
    # Remove www.
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    # Translate Semantic to Get
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*) /index.php?url=$1 [L,QSA]

    *note* do not use that last part, it is just an example of proper canonical url rewriting.. i am a firm believer in http://no-www.org/ .. i haven't typed a www since the 90s except for sites that don't know how to properly configure their servers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •