Custom error page status

If you want to use a custom error-page, I’ve read you have to pass the error-status.
Does that require something specific in your error.php?

Or do you only have to put this lines in your .htaccess? At the bottom, on top, does not matter?
ErrorDocument 400 /error.php
ErrorDocument 401 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php

Try one and see if it works? 404 is a good one to start with, since it is easy to test.

Try the format you have specified to start with, to get it working. Then, you could try the following construction:

 ErrorDocument 404 /error.php?error=404

If that does not work, try looking in the server vars to see if the HTTP response code is in there:

print_r($_SERVER);

Edit .htaccess file
Open it and add the following line:

ErrorDocument 404 /not-found-page.html
…where /not-found-page.html is the full path to the new custom 404 page that you’ve created.

1 Like

Is it possible to make the error-page appear on a page like list.php?id=5 where id=5 doesn’t exist anymore (but id=3 or something still does exist)?
I now use php header location, but this probably won’t make the non-existing id’s/pages disappear in search engine results?

Can you explain your problem a little more?

I use a php-page that takes data from a table (mysql db) with a GET id in the URL (list.php?id=1).

I deleted some rows in that table since the renewal of the website: but that specific page still appears in search engine results.
list.php?id=5 does not exist anymore, so it would show an ‘empty’ page.

After a mysqli_num_rows check, I use <?php header ('Location: http://www.domain.com'); ?> to redirect if that ‘id’ does not exist anymore.

But this will probably not make this specific page (for example: “list.php?language=en&id=5” or “en/list/5”) disappear in search engine results?