Vin Vin - 1 year ago 150
PHP Question

Trigger 500 Internal Server Error in PHP and display Apache error page

How can i trigger 500 Internal Server Error or 404 Page Not Found Apache errors in PHP?

For 500 Internal Server Error i have tried following code :

header("HTTP/1.0 500 Internal Server Error");

But it shows me a blank page.
How can i show the error in Apache's default format?

Please guide..

Vin Vin
Answer Source

After such a knowledge-full discussion, i think there is no php code can display the by default 500 Internal Server Error. The solution is :
1. Create a folder named http500 next to the php file.
2. Create a .htaccess file in it and add following code :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^])(.(*/
    RewriteRule ^])((a-zA
  1. PHP redirect code :

header('location : http500/');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download