However note that you are setting ErrorDocument
incorrectly which is causing external redirection and returning you 200
instead of 404
, 403
etc. Set your ErrorDocument
as follows without domain name:
ErrorDocument 403 /error.php?e=403
ErrorDocument 401 /error.php?e=401
ErrorDocument 400 /error.php?e=400
ErrorDocument 500 /error.php?e=500
This will keep original not-found URL in your browser while returning correct HTTP status code.
About your code:
You're setting variable $error_no
and using $error_code
in header()
function. You should use:
if($_GET['e'] == '404' || $_GET['e'] == '403' || $_GET['e'] == '500' )
{ $error_no = $_GET['e']; } else { $error_no = '200'; }
header(' ', true, $error_no);