Let’s just say you’re surfing along the web, googling your little heart out until it’s content.
You click from one search result to the next.
All of a sudden you arrive at one search result only to figure click around the website, arriving at an error page that’s quite amusing (see below):
Now didn’t that make you smile? And if not, then may reading a few more just like it will.
Now you may be wondering what this has to do with a 404 error page.
Well, a typical error page looks like the following below.
It’s dull, and not as lively as it could be, especially not as uniquely designed as the aforementioned 404 Error pages.
In addition, it’s more effective experience for both users and search engines when custom 404 error pages.
By now, you’re probably wondering how to create you very own custom error page?
Well, .htaccess is here to the rescue. There are quite a few http response codes that a user could encounter while actively using your website.
I won’t cover them all, but will cover the ones I think are important.
Without further ado, you use the ErrorDocument directive to create custom error code pages.
ErrorDocument <error code> /path/to/file
Below are examples for the various types of custom error pages I account for when using .htaccess.
ErrorDocument 400 /400.php // Bad Request
ErrorDocument 401 /401.php // Authentication Required
ErrorDocument 403 /403.php // Forbidden
ErrorDocument 404 /404.php // Not Found
ErrorDocument 408 /408.php // Request Timeout
ErrorDocument 414 /414.php // URI Request Too Long
ErrorDocument 429 /429.php // Too Many Requests
ErrorDocument 500 /500.php // Internal Server Error
ErrorDocument 502 /502.php // Bad Gateway
ErrorDocument 503 /503.php // Service Unavailable
ErrorDocument 504 /504.php // Gateway Timeout
ErrorDocument 511 /511.php // Network Authentication Required