Help Needed: 301 redirect? to www or not to www, that is my question

Discussion in 'Apache' started by browntwn, Apr 24, 2006.

  1. #1
    Okay, I hate asking questions here, as I know it must have been asked and answered dozens of times, but I can't figure it out on my own.

    I have a popular site, 20,000+ uniques a day, most from google searches. That makes me hesitant to change anything, for fear of ruining something I don't understand.

    I have limited knowledge when it comes to programming, I am more of an idea man.

    Anyway, here is my issue. Since I didn't know any better a bunch of links on my site go to:

    www.sitename.com/page.html

    some to:

    sitename.com/page.html

    some to:

    /page.html (these originate on both the www and no www pages)

    I see both in my refferal logs.

    ex from my stats page:
    Top 30 of 15157 Total Referrers
    # Hits Referrer
    1 185965 8.14% - (Direct Request)
    3 92314 4.04% http://www.sitename.com/
    25 12206 0.53% http://sitename.com/

    I first realized this was a problem when I created sitemaps for google. But I think I rigged those to work, by actually adding my site both ways, each with the same content and sitemap to google, one with the www.sitename.com and one under sitename.com.

    Now I am thinking it is a bad system for PR reasons, and SEO, but I am not sure.

    QUESTION 1: Is this something I need to fix?

    QUESTION 2: it seems like I would need to do a simple 301 redirect from sitename.com to www.sitename.com. Is that the solution?

    QUESTION 3: If I make that change, does any page that was entered sitename.com/anyfolder/anypage.html automatically go to it's www equivilent? (would the example url go here: www.sitename.com/anyfolder/anypage.html?)

    QUESTION 4: Last but not least, how the heck to I do do the actuall 301 redirect. Do I need to change the conf file and then htaccess?

    Yes, I did search first. I checked probably a dozen threads, these are some examples I looked at:

    http://forums.digitalpoint.com/showthread.php?t=76678&highlight=301+redirect+www
    http://forums.digitalpoint.com/showthread.php?t=23044&page=14&highlight=301+redirect+www
    http://forums.digitalpoint.com/showthread.php?t=75075&highlight=301+redirect+www


    Thanks for any guidance, it is most appreciated.
     
    browntwn, Apr 24, 2006 IP
  2. browntwn

    browntwn Illustrious Member

    Messages:
    8,347
    Likes Received:
    848
    Best Answers:
    7
    Trophy Points:
    435
    #2
    Nevermind. Solved it myself.
     
    browntwn, Apr 26, 2006 IP
  3. hasitruparel

    hasitruparel Peon

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    can you tell me how did you solve it? i am having the same problem
     
    hasitruparel, May 12, 2006 IP
  4. PaulMellors

    PaulMellors Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    From http://www.webconfs.com/how-to-redirect-a-webpage.php

    Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
    The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^domain.com [nc]
    rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

    Please REPLACE domain.com and www.newdomain.com with your actual domain name.

    Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
     
    PaulMellors, Aug 9, 2006 IP
  5. Cryogenius

    Cryogenius Peon

    Messages:
    1,280
    Likes Received:
    118
    Best Answers:
    0
    Trophy Points:
    0
    #5
    A new feature has been added to Google Sitemaps where by you can specify your preference between www and non-www domains:
    Quote from: Webmaster Central Blogs: More webmaster tools

    Cryo.
     
    Cryogenius, Aug 9, 2006 IP