How To Create Your Own 404 Page

A 404 is an error message that happens when the browser cannot find the page that it has been directed to. The default 404 error page can be a little boring, not give the user the type of information you wish to give and in some cases don’t even give a link back to the sites homepage. This simple tutorial will show you how to apply your own custom 404 error page.

Notes before we begin:

Not all web hosts allow you to do this, best way to check is to search their support files, or ask them.

This tutorial is for Apache web servers and involves editing the .htaccess file. Other web servers use different methods to display such pages and sometimes require you contacting your web host to get them to redirect the error to your chosen page.

Step One – Editing The .htaccess File

All you need to do is add this one line of code into your .htaccess file

 ErrorDocument 404 /error.html

This doesn’t need to be called error.html and also doesn’t need to use a .html extension. All you need to do is change the error.html part to whatever you want to call your error page.

Sometimes this file is hidden, so make sure that you can see hidden files on your server, if you don’t have this file on your server then you will need to create one. To do this open a text editor, add the code above and save the file as .htaccess, then upload the file to your root directory. If you have created your own file make sure that it doesn’t have a file extension (e.g .htaccess.txt), if it does you will need to remove this extension.

Step Two -Creating The Error Page

Create your custom error page and call it error.html (or whatever you renamed it to), you don’t need to add any special code to this page to make it into a 404 error, simply code it as you would any other. Once saved upload the page into your root directory and there you have it a custom 404 error page.

Have Your Say

Your email is never shared. Required fields are marked *
To add code to a comment use this [code] your code here [/code]