Posts Tagged ‘Custom error documents’

Custom error documents by htaccess file

I guess I should briefly mention that .htaccess is where most folk configure their error documents. Usually with sommething like this..

the usual method. the “err” folder (with the custom pages) is in the root
——————————————————————————-
# custom error documents
ErrorDocument 401 /err/401.php
ErrorDocument 403 /err/403.php
ErrorDocument 404 /err/404.php
ErrorDocument 500 /err/500.php

You can also specify external URLs, though this can be problematic, and is best avoided. One quick and simple method is to specify the text in the directive itself, you can even use HTML (though there is probably a limit to how much HTML you can squeeze onto one line). Remember, for Apache 1; begin with a , but DO NOT end with one. For Apache 2, you can put a second quote at the end, as normal.

measure twice, quote once..
———————————————————————————
# quick custom error “document”..
ErrorDocument 404 “<html><head><title>NO!</title></head><body><h2><tt>There is nothing here.. go away quickly!</tt></h2></body></html>

Using a custom error document is a Very Good Idea, and will give you a second chance at your almost-lost visitors.

What can I do with htaccess files?

Almost any directive that you can put inside an httpd.conf file will also function perfectly inside an .htaccess file. Unsurprisingly, the most common use of .htaccess is to..

Control access
Custom error documents
Password protected directories
Get better protection

500 error
custom directory index files
Save bandwidth with .htaccess
Hide and deny files