Forum Moderators: phranque
I'm a newbie here, so forgive me if this problem has been addressed elsewhere.
Basically my site is listed on Google, with all pages unique apart from one page very similar to the following example:
www.example.com/?some-site.com_id_110501_question
This "page" appears in Google's supplemental index and I'd prefer to get rid of it because it's a duplicate of the main domain:
www.example.com
I can't tell Google Webmaster Tools to delete the duplicate, because it's basically the home page with a hijacked parameter appended. (I'm surprised Google indexes this.)
I'm aware of htaccess 301 redirects, but only the basics of redirecting and old page to a new page, like this:
redirect 301 /old/old.htm http://www.new.com/new.htm
Is there any way to use htaccess to remove the ?some-site.com_id_110501_question so the page disappears from Google's radar and eventually drops out of the index by itself?
Any help you can offer is appreciated.
Mac
[edited by: jdMorgan at 3:37 am (utc) on Oct. 15, 2007]
[edit reason] examplified [/edit]
I have code in my htaccess file to redirect inbound links pointing to domain.com to transfer to www.domain.com (to transfer maximum google pagerank).
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
</IfModule>
I tried inserting the code provided in the previous replies, but it has no effect on the domain name string. Placing it within or without the <If tags makes no difference.
Also, be sure you've completely flushed your browser cache after changing the code on your server. Otherwise, your request will be served from cache, and will not be sent to the server.
Jim
Okay, it was a cache problem. I wasn't aware the cache needed to be cleared for .htaccess.
Now I know.
For future reference, I confirm the following lines will remove the specified string from your URL:
RewriteCond %{QUERY_STRING} some-site\.com_id_110501_question
RewriteRule ^$ http://www.example.com/? [R=301,L]
e.g. If your page is listed in Google as:
www.example.com/?some-site\.com_id_110501_question
then the above code will 301 redirect to:
www.example.com/
Just change the
some-site\.com_id_110501_question
to whatever string you want removed.
Thanks for your help guys. Great job.
Mac
[edited by: jdMorgan at 3:35 am (utc) on Oct. 15, 2007]
[edit reason] examplified [/edit]
Put the more-specific query string rule ahead of your "www" rule, so as to avoid stacked redirects for the query string.
Jim
This is inefficient, and according to current thinking, less than optimal for passing PR -- The evidence indicates that PR is preserved through one 301 redirect, but not always through more than one.
So a good rule of thumb is: Place external redirects first, ordered from most-specific pattern to least, then place internal rewrites, again ordered from most-specific pattern to least.
Jim
[edited by: jdMorgan at 3:36 am (utc) on Oct. 15, 2007]