How can I override Apache 404 status in PHP?

I have a PHP site set up using a 404 page to handle pretty urls and some caching. This works quite well and is faster than normal htaccess redirect rules under heavy load.

ErrorDocument 404 /damncache/index.php

      

The problem is Apache is setting the HTTP status to 404 and I cannot override it. Hence, when Google indexes a site, all of these pages are not indexed (according to Google Webmaster Tools).

This is how I am currently trying to override it:

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

      

With this, it works fine for people / browsers, but Google seems to get a 404 status and stop. Here's an example .

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

+3


source to share


1 answer


http://web-sniffer.net/ reports the headline 200 OK - have you given Google enough time to re-crawl the pages?



If he has already removed them from the index, you may need to submit them again - he can pick them up by crawling other links, but the sitemap in Webmaster Tools is probably a good idea.

+1


source







All Articles