There are many incidents when you see 404 error on your server log. Generally 404 error happens when a visitor type wrong URL and try to access the page which doesn’t exist. 404 error also happens when somebody visits a page from a backlink with wrong URL.
If you have not set the custom 404 error page then the visitor is going to see the usual 404 page as shown in the following image.
Traditional 404 error page only contains information about 404. There is no other information or there is no link to your website on the error page. So when a visitor comes to your website and see 404 error page, the visit doesn’t have any choice than closing the browser. It takes lots of efforts and work to get a visitor on your site. All your work goes in vain if visitor leaves your website without reading a word from it.
If you set a custom 404 error page then the visitor will have choice to browse through other pages of your website. That way you don’t lose your potential customer.
Create Custom 404 Page
For setting custom 404 page, you first need to create the custom 404 page. So create the page and give it any name. You can choose any name you want. For the demo, I am going to use notfound.html page.
In this page, you can give information about the 404 error. You can also include the navigation links so that anybody can visit other pages of your website. It is a good practice to include the sitemap link and a google search box on the custom 404 page. So a visitor can search in the website. This is how my custom 404 page looks like.
Set Up 404 Redirect
Now the custom 404 page is created and it is ready to be set as new 404 error page. We need to redirect the request of a user to this custom page when 404 error happens. You can do that using .htaccess file. Just include the following line in the .htaccess file.
ErrorDocument 404 /notfound.html
If you can’t see the .htaccess file under the root directory of your website then create the simple text file and give it a name .htaccess. Add the above entry and save the file.
You also need to upload notfound.html file on the server. Make sure that notfound.html is accessible. For this website, you can visit the notfound.html page by visiting the URL https://dhdjdj.com/notfound.html.
Your custom 404 error page is set now. Just visit any random URL which doesn’t exist on your server and make sure that you see the notfound.html page.
For this website, you can visit https://dhdjdj.com/abcd to check the custom 404 setup. Since /abcd doesn’t exist on my server, you should see the output of notfound.html on the same page.
I hope you got the idea of setting custom 404. Now go and set the custom 404 page on your website.