如何在PHP中覆盖Apache 404状态?

I have a PHP site set up using a 404 page to handle pretty URLs and some cacheing. This works quite nicely, and faster than the usual htaccess redirect rules under heavy load.

ErrorDocument 404 /damncache/index.php

The problem is that Apache sets the HTTP status to 404 and I cannot seem to override it. Consequently when Google indexes the site all of those pages are not indexed (according to the Google Webmaster tools).

Here's how I am trying to override it at present:

header($_SERVER['SERVER_PROTOCOL'] . " 200 OK");
header("Status: 200 OK"); // for fast cgi

With this it works fine for humans/browsers, but Google apparently receives a 404 status and stops. Here is an example.

It's hosted on a Dreamhost dedicated Linux server running PHP 5.3.x with FastCGI.

http://web-sniffer.net/ reports a 200 OK header - have you given Google enough time to recrawl the pages?

If it has already removed them from the index, you may need to submit them again - it may pick them up by crawling other links, but a sitemap in webmaster tools is probably a good idea anyway.