Custom 404/403 Error Pages
Everyone knows what an error page is — that dreaded 404 'thing' that appears when someone hasn't updated their website properly, or has accidently deleted a page. Of course, we sometimes get them when we mistype URLs too; they're not always the webmasters fault. Anyway, did you know you can (if your host allows .htaccess files) customise your error pages to give a new and funky personal message to your visitors?
All of the error pages can be customised, not just the 404. However, the two most common that your visitors will come across are 404 and 403, therefore you'll save time just creating/editing these.
Error pages can be created like any normal HTML/PHP/etc web page — they can be customised with CSS and decorated (althought probably unnecessarily) with fancy images. Once you've created your web pages, save them in the root directory of your web site (where index.html/php is stored) and give them sensible names like 404.html or 403.php — based on whatever file extension you would usually use.
Once you've created the pages you need to create a .htaccess file in which you'll place the coding that tells the browser where to find your error pages. As most Windows Operating Systems will not allow you to create a file starting with a full stop (period), I find it easier to name the file htaccess.txt and then rename it after uploading it. So, create a file using Notepad called "htaccess.txt".
In the htaccess.txt file, you need to type the following:
ErrorDocument 404 http://www.domain.com/404.html
Don't forget to replace domain.com/404.html with the URL to the error file — wherever you've uploaded it — and 404 with the correct error number. If you've customised multiple error pages, place that same text onto a new line in the same document, replacing 404 with the number for each error page as well as the correct URL. For example, I have customised my 404 and 403 error pages, so my htaccess.txt file looks something like this:
ErrorDocument 403 http://www.jemjabella.co.uk/403.html
ErrorDocument 404 http://www.jemjabella.co.uk/404.html
Once you've added the lines which reference all of your new error pages, upload the htaccess.txt file to the root directory of your host (where index.html is stored) and then rename it to .htaccess — including the "." before the word htaccess. To test if a new 404 error page is working, simply type in your URL followed by /jklsdkls — or some other 'fake' address and your 404 error should present itself. To test a 403 page, you will need to attempt to access a directory/file which has indexes turned on.
Tags:
403, 404, htaccess,
Last Updated On: 08th February 06 by Jem
Bookmark At: StumbleUpon, Digg

Handy Stuff
Downloads
Friends of 'TT'
Resources