A few weeks ago, one of our consultants told us that when a file not found was issued on our servers, it was reporting a 302 redirect.
To test it, I entered a bogus page for our website in the browser
Looking at the Apache access log, I was quickly able to find the line reporting this.
grep bogus.cfm virtual_log
192.168.0.x - - [19/Apr/2010:10:05:25 -0400] "GET /bogus.cfm HTTP/1.1" 302 316 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:22.214.171.124) Gecko/20100401 Firefox/3.6.3 GTB7.0 (.NET CLR 3.5.30729)"
Also, using the Firefox's Web Developer tools -> Information -> View Response Headers, I saw a 302 response code.
It turned out one of our Coldfusion scripts was doing a redirect using cflocation. I changed it to CFHEADER to issue the 404 status code and then another cfheader to perform the redirect.
After having the consultant review the fix, he came back and said he was still seeing the problem. He never actually gave me the example he was using the first time, so when I asked him to send me one, it turned out he wasn't accessing a file with an extension, but what could have been a directory.
I was able to recreate the problem, but was somewhat perplexed as to what caused it. After digging around a bit, I checked an .htaccess file to find our ErrorDocument was specified in it. Not really knowing what was wrong, I decided to try removing the domain part of the url to make it relative. So
ErrorDocument 404 http://www.mysite.com/NotFound.cfm
ErrorDocument 404 /NotFound.cfm
After checking the Apache access log, I no longer saw 302 and only saw 404. I can only guess it was assuming that it had to redirect to another website, so issued the 302 to www.mysite.com, not caring that it was already on that site. Changing it to a relative location made it not have to explicitly go to that URL and not having to issue the extra 302 status code.
192.168.0.x - - [19/Apr/2010:10:01:38 -0400] "GET /bogus HTTP/1.1" 404 36637 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:126.96.36.199) Gecko/20100401 Firefox/3.6.3 GTB7.0 (.NET CLR 3.5.30729)"
I sent this out to our consultant for review again and hope to get a positive response.