views:

34

answers:

1

This is actually a two-part question. My server is set up to redirect all 404 errors within Apache itself to index.php?404. Does this still send a 404 status message to the client to tell them the page was not found, and then display my customized 404 error page? Because I also have processes within other pages. While the page itself may exist, if the username (for example) is invalid or does not exist, it simply displays the same 404 page straight from the file (includes the 404 page and dies). Should I be using PHP to send an additional 404 status to tell the client the page didn't exist and if so, how do I do that?

Edit:
To further explain the problem above:
admin.example.com -> admin is a valid username and will display pages
madeup.example.com -> madeup is an invalid username and will output the 404 page
*.example.com redirects to index.php for processing, so search engines, etc will think the page exists because it got processed then I simply outputted a 404 page and killed the script...

I recently had a problem where Google cached a page that was a 404 error so I was trying to figure out how to prevent search engines, etc from caching or reading pages when they send out the 404 page when the page technically exists. Are there other, better alternatives?

A: 

If the 4nn/5nn error page has an actual HTTP status header of 200 OK, then it will be indexed.

So, you need to ensure that it's been sent along with the correct HTTP status header. This fault is often caused by sending a redirect to the error page instead of a forward/include. A redirect basically instructs the client to fire a brand new request to the server, which would always result in 200 OK. You would like to programmatically modify/set the header inside the error page, e.g.

header('HTTP/1.1 404 Not Found');

You can determine the actual HTTP status code using tools like Firebug and Web Developer Toolbar.

BalusC
How can I use Firebug to check the status code?
animuson
In the [Net](http://getfirebug.com/network) panel.
BalusC