ilhan
ilhan

Reputation: 8952

How I'll let PHP to show the default error page of the server?

If the ID (ie user) does not exist I send header("Status: 404 Not Found"); to the browser but PHP sends rest of the page too. Then I made it to send nothing but then it showed a blank white page. I want it to show the default error page. How I'll let it to do it?

Upvotes: 0

Views: 766

Answers (4)

vertazzar
vertazzar

Reputation: 1053

you can set it via htaccess also,

ErrorDocument 500 http://foo.example.com/500.php
ErrorDocument 404 /404.php
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php

depending on http status response

Upvotes: 2

K. Ober
K. Ober

Reputation: 63

I think that in this case, if you only set the header, you'll get the default error page of your browser and not of your web server. The problem is that the page exists for the webserver. So if you know where your server's error page is stored, read it from there. And make sure that your response is longer than (I think it was) 512 Bytes, otherwise the browser (especially IE) will give you it's very own error page.

Upvotes: 1

delete me
delete me

Reputation:

Add die; after the header call as well.

Upvotes: 2

Your Common Sense
Your Common Sense

Reputation: 157872

header("Status: 404 Not Found");
readfile ($_SERVER['DOCUMENT_ROOT']."/404.html");
exit;

? or you need universal solution?

Upvotes: 1

Related Questions