Create a Custom 404 Error Page on Apache Server

What is 404 Error?
404 error page occur when the requested resource is not available in the server. 404 error is generated when user mistypes the url or the requested page is removed from the server.

404 error page as shown on Mozilla Firefox is given below


So to avoid this annoying 404 error page we can create our own good and attractive custom page and replace it with that. Custom page lets the user remain in touch with the site and at the same time have the choice to navigate and explore the other pages of the website without clicking the back button.

Create a Custom Error Page for Apache Server using .htaccess File

1. Look in your root directory for the .htaccess file. If it is not available there create one.
2. Create the custom 404 page (404errorpage.html) that you want to appear in place of default 404 error page.
3. Add the following code in your .htaccess file

ErrorDocument  404 /404errorpage

File path must start using a slash “/” as it tells the server to start looking in your root directory

You can also write the following code

ErrorDocument 404 http://www.

After creating the custom 404 page don’t forget to make your custom error page noindex and nofollow. Else search engines add this page to their results database.
Add the following meta tag inside the <head></head>


<meta name="robots" content="noindex, nofollow">


Here you are with your custom 404 error page.