Correct 301 redirect?

Discussion in 'Site & Server Administration' started by athlonin, Sep 22, 2006.

  1. #1
    Hi Guys,

    I am trying to redirect my www links to the non-www version. I am using the code below, but I am not sure it's correct because I'm having trouble getting indexed properly. Please confirm. Thanks!

    RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
    RewriteRule ^(.*) http://example.com/$1 [L,R=301]
     
    athlonin, Sep 22, 2006 IP
  2. MrX

    MrX Well-Known Member

    Messages:
    1,563
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    140
    #2
    Explain your indexing problem. Your code looks correct...when you go to www.yoursite.com, you get redirected to yoursite.com, right? So the redirection is working correctly.
     
    MrX, Sep 22, 2006 IP
  3. athlonin

    athlonin Guest

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes. The redirect works from the non-www to the www. I thought maybe the redirect was in error, causing my site not to get indexed. However, I think the reason for the poor indexing is due to the same metatags throughout the site, which I have now changed.

    Thanks for confiming that the redirect is ok.
     
    athlonin, Sep 23, 2006 IP