Duplicate pages because of "/?" after domain

Discussion in 'Apache' started by myhart, Jun 3, 2008.

  1. #1
    I recently bought a domain that now has duplicate content indexed in Google. Example "mydomain.com/?foiffs=in100fweg" which displays the same page as "mydomain.com/". I have tried to use a 301 redirect without any luck. Any suggestions? Thanks!
     
    myhart, Jun 3, 2008 IP
  2. myhart

    myhart Peon

    Messages:
    228
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Seems quite a few apache websites may be prone to this same problem. Even DP will show duplicate content when a question mark is added after the domain. My biggest problem in finding an answer was figuring out what to search for (query string dupilate content tracking url)? Anyway after a few more hours of searching I found an easy solution on the following two websites.

    The first solution by jdMorgan removes the question mark on the end of the url. Be sure to change example.com to your domain!

    http://www.webmasterworld.com/apache/3216645.htm

    # Remove question mark if blank query string 
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^?]*\?\ HTTP/ 
    RewriteRule (.*) http://www.example.com/$1? [R=301,L]
    Code (markup):
    While the above removes the question mark I needed the following to remove the query string that was causing the problem of dublicate content on my website. Change the "ref" to whatever your query string starts with.

    http://www.the-art-of-web.com/system/duplicate-content/

    RewriteCond %{QUERY_STRING} ^ref=
    RewriteRule (.*) /$1? [R=301,L]
    Code (markup):
    I hope this helps anyone with similar problems in the future!
     
    myhart, Jun 4, 2008 IP