lucy24 - 1:12 am on Jan 25, 2012 (gmt 0)
You need to look from the other end. What happens when someone requests a pseudo-directory (I assume you're rewriting from displayed directory to actual query) or uses a bogus query term? What should not happen is that your site goes ahead and creates a page.
A custom 404 page is very very unlikely to be the problem. Error pages are for humans. Robots just note the 404 and carry on. Unlike humans, they can even choose not to follow redirects.
Even in the Parameters area of gwt and similar, there's no way to say "Ignore everything except...." So you need to make sure that spurious parameters-- or impossible values-- aren't being processed in the first place.