We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Create a Custom 404 Page in Apache

Posted Jul 10, 2012 90.4k views Apache

Why Create a Custom 404 Page

A custom 404 page lets you provide a user-friendly website to your visitors even in the midst of an error. Very few users, when presented with a 404, will do more beyond click back to get out of the mistake. A custom 404 page is a good opportunity to keep them on your site and do more to redirect them to their destination.


Before going through this tutorial, you should already have created a custom 404 page and saved it into your website's directory.

Implement the 404 Page

To edit the 404 page, open up or create the site's .htaccess file. You can create it in a text editor and upload it to your site via the FTP server. Keep in mind that the name of the file has to be simply .htaccess.

Add the following line to the file, replacing new404.html with the correct new error page name:

ErrorDocument 404 /new404.html

Save and Exit.

Keep in mind that the Apache looks for the 404 page located within the site's server root. Meaning that if you place the new error page in a deeper subdirectory, you need to include that in the line, making into something like this:

ErrorDocument 404 /error_pages/new404.html

See the 404 Page

Now visiting unavailable pages on your site should display your custom 404 page!

By Etel Sverdlov


Creative Commons License