Customizing the Error Pages Served by
Apache to External Web Browsers
I used this method on SME 6.01. I suspect it will work on
SME 5.6, but I have not tested it. If you try it on 5.6 or other
versions and it works let me know at:
arnoldo_AT_bertoncini.net and I will add that to this how-to.
1. Make a directory for the template fragment:
If you have made previous changes to the http.conf template, skip to
Step 2. If you are unsure check by trying step 2 and proceed from there
if the directory already exists, if you get "No such file or directory"
then do this:
mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/http.conf
2. Create a template fragment in the above directory called
11ErrorDocs.
cd /etc/e-smith/templates-custom/etc/httpd/conf/http.conf
pico 11ErrorDocs
3. Add lines referencing the error types you want redirected to
your custom page in the 11ErrorDocs file with pico or whatever text
editor you like:
ErrorDocument 500 /filenotfound.html
ErrorDocument 404 /filenotfound.html
ErrorDocument 401 /filenotfound.html
ErrorDocument 403 /filenotfound.html
ErrorDocument 402 /filenotfound.html
Save and close. You can do just one of those error types or any
combination
you like. You can name the html file whatever you like, or use cgi,
perl or php
files if you prefer. You can also specify a different filename for each
error type. Just make sure the filename(s) are used in the next step.
You can also place them in a sub-directory, just make sure you use an
absolute path to whatever file you are using in the 11ErrorDocs
template fragment.
You can also output a simple custom message like this:
ErrorDocument 403 "Sorry can't allow you access today
The error type definitions are documented here.
The Apache ErrorDocument directive is documented here.
4. Create a custom error page(s).
Make sure it is at least 512 bytes long because Microsoft Internet
Explorer can substitute it's own "friendly" error page if it is not,
see Q294807
for details. Use the same filenames and/or
subdirectories from the 11ErrorDocs template fragment and place it in
the primary ibay or the subdirectory if that's what you used in Step 3:
/home/e-smith/files/ibays/Primary/html
5. Expand the template
/sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf
6. Change file permissions:
chmod -644 /home/e-smith/files/ibays/Primary/html/filenotfound.html
7. Restart the http server
/etc/rc.d/init.d/httpd graceful
Type in a filename you know is wrong to test it:
http://www.mydomainnane.com/foobar
If you still get the same tired old 404 page, clear browser cache and
try again.
References:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
http://httpd.apache.org/docs/custom-error.html
http://httpd.apache.org/docs/mod/core.html#errordocument
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q294807
http://contribs.org/modules/pbboard/viewtopic.php?t=23504
http://contribs.org/modules/pbboard/viewtopic.php?t=17159