Creating a Custom 404 File Not Found Error Page

Creating a Custom 404 File Not Found Error Page

With some web hosts a file named missing.html or 404.html already exists in the www directory of your account. This is the page that is returned to the visitor when they attempt to visit a page that does not exist (resulting in a 404 error) on your account. You can edit this file to your liking, or create your own.

As long as it’s named missing.html (or whatever your web host’s default setting is) and it’s in your root www directory, the server will display it whenever someone tries to access a page on your domain that does not exist.

You can override the default missing.html specification by including the following directive in a .htaccess file:

ErrorDocument 404 /customerror.html

… where customerror.html is the name of the file you want to use as your 404 error page, and which you have placed in your main www directory.

For more information on .htaccess directives, see our post titled Fun with .htaccess.