Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've recently bought a domain that was unregistered. After looking in Google webmaster tools, Google is trying to crawl random pages that don't exist. Turns out it did have a previous owner.

The offending pages are in the style

mysite.com/catalog/?Brand=0&Model=102&ID=0

Although there doesn't seem to be any links on the web (who knows what the previous owner did) I want these to point to my homepage.

I've tried redirecting using..

redirect 301 /catalog/ http://mysite.com/

but I end up with a redirect to my homepage with an URL in the address bar of...

mysite.com/?Brand=0&Model=102&ID=0

How do I get it to just redirect to my homepage and show URL mysite.com in the address bar with no gubbings on the end?

I am on an Apache server with PHP 5

Thanks.

share|improve this question
    
Unless you have actual visitors hitting those URL's (in which case a 301 redirect page might be useful), wouldn't it be better to just respond with a 404? Google will see that those pages don't exist anymore and eventually stop crawling them. Even if visitors are hitting those URL's I'd still recommend using a nice, helpful, informative 404 page over a potentially confusing redirect. –  BigBagel Apr 16 '13 at 20:29
    
I didn't think of that. I though Google penalised sites with lots of 404 errors. –  Adam Apr 17 '13 at 18:55
    
You won't be penalized for responding to a request for a non-existent page with a 404. In fact, that's exactly the point of a 404. Here are a couple useful links: 1, 2 –  BigBagel Apr 18 '13 at 18:55
    
Thanks BigBagel, I was under the impression that 404 = bad site design and upkeep. Thanks for clearing it up. –  Adam Apr 20 '13 at 10:25

1 Answer 1

up vote 1 down vote accepted

Simply append a ? to the end of the domain in the redirect rule to prevent the query string from being append to the final redirected url.

RewriteRule ^catalog/.*$ http://www.mydomain.com? [R=301,L]
share|improve this answer
    
Amazing. Thank you for a quick reply that solved the problem! –  Adam Apr 16 '13 at 20:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.