In this article let us discuss about how to set up a custom 404 error page using .htaccess file. This will let display user a 404 error page when user try to access webpage not exists on server. Basically we must know why 404 errors occur? There are many cause for 404 error which of some are as follows: When a user try to manual type a url for page that doesn’t exist on server. Pages link were not updated when they move from one folder to other. Page link are defined incorrect also response 404 etc.
Let us see the steps to create 404 error page using .htaccess.
Step I : Create/Edit the .htaccess file
We can update .htaccess file either by using Cpanel or FTP .
Download the .htaccess file from root directory. Open it in editor.
If not exist, create a .htaccess file.
Now set 404.html as error document to display 404 error when page not exist. Put the given below snippet in .htaccess file.
ErrorDocument 404 /404.html
Step II : Create a Error Document file
Now create a 404.html page and upload it in root directory.
There is another option to set a 404 error message using .htaccess. Just copy the given below code in .htacess file and save it.
ErrorDocument 404 “<h1>Page is not found</h1>”
Upload this .htaccess file using FTP and overwrite it. Now error page(404) is successfully created for website. When a user try to access a webpage that do not exist will display 404 errors. That’s it 🙂 .