Dave's Brain

Browse - Computer Tips - How can I make a good/easy custom 404 (page not found) page?

Date: 2011oct15
OS: Linux
Product: Apache

Q.  How can I make a good/easy custom 404 (page not found) page?

A.  Add this directive to your httpd.conf file:

ErrorDocument 404 /404.cgi
Or it can be done individually for virtual hosts. Create the 404.cgi file that is mentioned:
#!/usr/bin/perl print <<EOF Content-type: text/html Status: $ENV{REDIRECT_STATUS} Condition Intercepted <head> <title>404 Not Found</title> <link rel=stylesheet href=/css/mysheet.css type=text/css> </head> <h1>Page not found</h1> <p> Sorry page $ENV{REDIRECT_URL} doesn't exist any more. <p> There is other good stuff on the <a href=.>home page</a> EOF
Make 404.cgi executable. Restart Apache.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.