Custom 404/500 Errors via .htaccess

Creating custom pages for 404 (page not found) and 500 (internal server error) errors are super simple. In fact it’s so easy, it’s almost not worth a blog entry. But what the hell.

To get a custom error page rolling, create an .htaccess file with the following:

ErrorDocument 404 /path/to/error/file.404.php
ErrorDocument 500 /path/to/error/file.500.php

Place the .htaccess file in the root directory of your website.

Now when people get a 404 or 500 error, they’ll be directed to your custom error page!

I had some fun creating a custom 404 page for my website - check it out.

1 Comment so far

  1. [...] advantage of custom error documents usually requires tapping on an .htaccess file, as discussed in my previous custom error article. However CakePHP makes for easy custom error handling thanks to a pre-defined Cake [...]

Leave a Reply