Specifying your own error pages with .htaccess
In this quick tip we are going to specify our own error pages with the
Usually when a user tries to open a page on a website that doesn't exist, he gets a standart error message from
the server. If you want to create your own error page (PHP/HTML...), and then display it when a user tries to open a file that doesn't exist, you can set that easily with the
.htaccess file. The only thing you need is an own error page which you saved on your website-server.
Please note that error pages should be designed to easily help visitors, so an error page should be kept short and "clean".
Here is an example of an error page:
After saving this (or your own) file on the server, you can add this to your
ErrorDocument *** /errors/test.php
The stars have to be replaced by the matching HTTP Status code. For example
404 is the code of "page not found".
errors is the name of the folder where the error files are saved (of course you can save the error files wherever you want). You can replace
test.php with any other file. You can use this rule
multiple times, if you also want to set your own error pages for other HTTP Status codes.
Read more about HTTP Status codes.
This is how the code looks for HTTP Status code
ErrorDocument 404 /errors/404.php