Don’t lose and confuse your guests – custom 404 error page
Yesterday I wrote a post on how to add a custom 404 error page to Concrete5. It has since been pointed out to me that I should show how it is done outside of a CMS.
Why should we create a custom 404 error page anyway?
Well, it’s just nicer to your site visitors – if you read usability guides it is always cited that a custom 404 page is imperative. The standard one that comes with your browser tends not to be very nice or friendly.
Depending on what has caused the error you can get some odd behaviour and messages in firefox.
Fortunately it is dead easy to do: all you need to do it edit your .htaccess file.
Your page can be called whatever you want: in this example I’ve called it 404.php and my entry in my .htaccess file is as follows:
ErrorDocument 404 /404.php
This is pointing to the file 404.php in the root of your website so you’d better make sure that is where you uploaded it.
With this added and uploaded your custom file will be displayed every time a 404 error is encountered – which hopefully will not be that often.
You can also use this method to handle other errors – 500, 400, 401 etc so that in the event they occur they never scare off your visitors.
Of couse if you can also add script (as in our example above – this is a php file) to your custom error page then you can also do some more clever stuff like log the referrer details, send you an email etc. You can put whatever you like on the page and encourage your visitors to persevere with the site.