I have followed Microsoft's instructions for custom 404 pages in SharePoint by setting the web application's FileNotFoundPage property. I am now still getting a 404 error if someone types a site collection name incorectly. For example if the user goes to sharepoint/sites/test and "test" is not a site collection then they will still get a 404 error. I have tried catching this with a httpModule also, but it looks like the request is returing a 200 code instead of a 404.
Several of the blogs mention this same problem but I have not seen any solution for it.
"* This seems to be working within a site collection context only, i.e. http://MyMOSSServer/sites/siteA if sites is a wildcard inclusion managed path and siteA doesn't exist in MOSS then this URL will NOT trigger the custom 404 error page set to SPWebApplication.FileNotFoundPage property."