Here's a strange one that took me a while to find on the net.
I have setup a site using the Context.RewritePath method to give pages on the site friendly looking URLs in .NET which kept on returning 404 errors after loading one of these URL's 10 times. It so happend that the trace setting in my web.config was set to 10 and when I increased it so did the amount of times RewritePath worked until it returned a 404.
It appears the problem is actually a bug with RewritePath and to get around it you need to use the other overloaded method which takes three parameters instead of 1, odd but true..