403 and 404 error handling

Gerard Beekmans gerard at linuxfromscratch.org
Thu Sep 18 21:00:28 PDT 2003


Old config had Apache configured to redirect to
http://www.linuxfromscratch.org/404.html in case of a 404 error (page
not found). The problem with the old setup was that if you made a typo
in the URL input field, the redirection would replace your typo with the
404.html location and your own entry (plus typo) would be lost. I found
it a pain to have to rewrite it all again, especially if it was a long

So I made some changes so the page is served but not as a redirect. This
was done by putting 404.html in the /home/httpd/error/ directory and the
URL hostname/error/ is an alias to that dir, so the same file will work

The 404.html that's in www.linuxfromscratch.org wouldn't do because it
uses relative links which then requires the style and images directory
in whatever dir the error occured, ie:

[Thu Sep 18 21:55:59 2003] [error] [client] File does not
referer: http://archives.linuxfromscratch.org/lfs-museum/5.0-pre1/bah

So, I took 404.html and put it in /home/httpd/error/ and changed all the
style and images URls to /error/images/ and /error/style/ (and created
the /home/httpd/error/{style,images} symlinks to

403.html is almost identical to 404.html with just a few changes as to
the meaning of it. Check http://www.linuxfromscratch.org/error/403.html

Now it works no matter where the error occurs.

Okay, this is where Jeroen comes in: can you maintain this file? The
404.html file in www.linuxfromscratch.org isn't needed anymore. Mirrors
never configure (as far as I know) to use the file (and that's fine with
me). The files are lfswww group writable and they may need to be fixed
up to be proper validating HTML and all that (I didn't check for that).

Let me know if anything isn't clear.

Gerard Beekmans

/* Linux Consultant --- OSDN / DevChannel *
 * Technical Writer --- CheapBytes        */

/* If Linux doesn't have the solution, you have the wrong problem */

More information about the website mailing list