Women in Technology

Hear us Roar



Article:
  Custom Error Pages with PHP and Apache
Subject:   Keep it simple and stupid
Date:   2006-09-01 12:05:39
From:   CagdasCubukcu
Very simple error page to help everyone get started.


Open apache configuration file httpd.conf probably at your "conf" directory in your Apache folder.


Search the line "ErrorDocument 404 /missing.html"
Uncomment it.
Change it as "ErrorDocument 404 /missing.php"


Create a new php page in your "htdocs" folder. Name it missing.php.


Put the code inside:
<?php
ob_start();
echo "<p>Page you are looking is not found :)";
header("Refresh: 2; javascript:history.back()");
?>


You are all set! When a page is not found, you will be directed to this page which will automatically take you back in 2 seconds.