I have a website with family trees, with over 1 million names (with their own page). It always was on Google's first page, but dropped a lot after the panda update. I have already changed a lot, determined to beat it .

I saw in Google webmster that it found a lot of soft 404 errors on my site (in which google says: the page doesn't exist and the server doesn't return a 404-error). The urls giving this error are often pages of names which are deleted from the family trees. So the page itself does exist (for example person.php), but the person itself is deleted (person.php?pid=34 -> person 34 was deleted) so there is no information on the page). So I put this code on the page:

I've read that putting a redirect in .htaccess is more common, but because I am not the one deleting the names, I think this is the more logical place for me, because putting a 404 error on a deleted name is automated.

I thought this was the answer, because when I click on the link I can see my own 404-page. But Google still gives the soft-404 error, so he doesn't see it as a proper 404?

It's clear that, while both Googlebot and you are ending up on the 404 page, the header response code the bot is getting is a 302 rather than a 404. I'm no script guy, so I can't guarantee that this is the reason, but I searched around a bit, checked 5 or 6 different sources, and every one of them specified

<?php
header("HTTP/1.0 404 Not Found");
?>

Some used HTTP 1.1, and one of them indicated that either would work and it just depended on which version you'd used on the rest of the site, but all of them stipulated "404 Not Found" instead of just "404". I don't know if changing that will make a difference, but I think it's worth trying unless and until someone else posts that I don't know what I'm talking about (because I don't).

Apart from that, I'm not sure if using a relative URL for the location of the 404 page is the right way to go, although it seems to be working for you when you test it. Have you tried requesting a nonexistent page at a URL buried deep within multiple levels of (nonexistent) subdirectories and seeing if you still get the 404 page?

I think you might be better off using .htaccess to point to the URL to be displayed in the event of a 404 response and just using the php to set that response. But again, this is not my field of expertise -- not even close

I'm back . For some reason I am still not getting the right 404 page all the time. I hope you can help me again.

This is the code in .htaccess:

ErrorDocument 404 http://www.mylink.nl/main.php?pagina=404

And this in map/template.php:

if($name == ""){header("HTTP/1.1 404 Not Found"); exit;}

if I go to map/template.php?name=existingname everything works as it should.if I go to map/notexistingfile.php?name=existingname I am getting the 404 error page as I should.

But if I go to map/template.php?name=notexistingname I am getting a white page.If I echo something just before header() it is echoed, so the code is being activated.If I use the google bot in google's webmaster area I can see a 302 is returned instead of a 404.

And if I go to map/template.php?name=notexistingname&someothervariables I also get a white page.

If I echo something just before header() it is echoed, so the code is being activated.If I use the google bot in google's webmaster area I can a 404 error is given, but the right page isn't show.

Still the same. I will give you some live examples, maybe that will make things clearer:

This is a good page: www.uwstamboomonline.nl/passie/sites/template.php?pid=1658

This is a not existing page: www.uwstamboomonline.nl/passie/sites/template.php?pid=1658-> it gives my custom error page www.uwstamboomonline.nl/404.html

Then when I use the right page but a not existing pid the code should be triggered, but it is not, it gives a white page: www.uwstamboomonline.nl/passie/sites/template.php?pid=16588

This is the code:

if($kid == "" OR $pid == "")
{
header("HTTP/1.1 410 Gone");
exit;
}

I changed the 404 to 410 (because most of those pages are indeed deleted pid's), but they both do not work, if I change it to a 302 or 301 it does work.

I could use a 302 redirect to my error page, but the problem I am trying to solve is that in my google webmasters there are a lot of errors saying something like 'the url does not exist and your server does not return a 404-error'. If they say that, than it should be possible to generate a 404 error, shouldn't it?

Then when I use the right page but a not existing pid the code should be triggered, but it is not, it gives a white page:www.uwstamboomonline.nl/passie/sites/template.php?pid=16588

This is the code:

if($kid == "" OR $pid == "")
{
header("HTTP/1.1 410 Gone");
exit;
}

All that code will do is send a HTTP header and then stop. it will NOT serve out the 410 document because the SERVER has not triggered the response, it has been done by PHP. If you want any content to be shown to real users YOU have to provide it in the same document.

The documents referenced in an ErrorDocument directive are only shown when the server handles the error.