What's the .htaccess that will solve double Google index?

Discussion in 'Apache' started by Bohol, Aug 20, 2009.

  1. #1
    Here's the situation.

    My primary domain in a webhost is example.com (just a sample)

    I built a website subdomain.example.com

    Google has been indexing the website as subdomain.example.com

    However, Google is also indexing example.com/subdomain

    How to stop Google and other search engines from indexing example.com/subdomain? Is an .htaccess the solution? Or there is another way of fixing it?

    I am afraid I would be penalized for duplicate content.
     
    Bohol, Aug 20, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    premiumscripts, Aug 20, 2009 IP
  3. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What is the code to use?
     
    Bohol, Aug 21, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's the code :) Just place that line in your htaccess file.

    redirect 301 /subdomain/ http://subdomain.example.com
    Code (markup):
     
    premiumscripts, Aug 21, 2009 IP
  5. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Oh, thanks premiumscripts. Should I do the same thing to all my subdomains?
     
    Bohol, Aug 21, 2009 IP
  6. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yeah, but just test this one first. If it works, OK, add the others, if it doesn't, remove the line again.
     
    premiumscripts, Aug 21, 2009 IP
  7. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If it doesn't work, do you have an alternative solution? Thanks again, premiumscripts!
     
    Bohol, Aug 21, 2009 IP
  8. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Not at the moment, if it doesn't work, just post in this thread again :)
     
    premiumscripts, Aug 21, 2009 IP
    Bohol likes this.
  9. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I see. Thanks premiumscripts for the tip.
     
    Bohol, Aug 21, 2009 IP
  10. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #10
    It seems that the code is working. I still have to find out whether Google has stopped indexing the folder.
     
    Bohol, Aug 21, 2009 IP
  11. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Good! Well, it'll be 301 redirecting to the subdomain, so eventually (in a couple of weeks) it should be gone from the googl index :)
     
    premiumscripts, Aug 21, 2009 IP
  12. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #12
    joebert, Aug 27, 2009 IP