Home » Internet » Web Designing » How to show a custom 404 page not found page on your website

How to show a custom 404 page not found page on your website

A 404 page not found error occurs when somebody arrives at a particular link on your website and the link either doesn’t exist or its original URL has been changed.  Whatever is the reason behind the absence of the link you have to inform your visitors what has happened and this can be done by displaying a 404 page not found page.

Many web hosting companies show a default page if such a situation arises but this doesn’t look professional and doesn’t give complete information to your visitors. They might end up thinking that it is a spurious website and nothing relevant exists there.  Most of the visitors are not patient enough to try the homepage; they may immediately navigate to another website, despite your website containing 100s of highly useful pages.

They may also be redirected to your home page when a page is not found, but this may end up confusing them. Some even think they that are being mislead.

You need a custom 404 page not found page that properly explains the situation and offer alternative options. The best thing to do is, offer a search box and encourage the visitor to search for the needed information. If you cannot use a search box, you can direct the visitor to your site map.

So how to show a custom 404 page not found page on your website?

Creating a 404 is not a problem, it’s just like any other page on your website, and in fact, you don’t even have to name it as 404.php or 404.html or 404.shtml. But let us, for the sake of better understanding, assume that you create a page called 404.php for your website and upload it into your root folder (where your index.php file exists). You have to tell the server to show this page in case a situation arises when a visitor arrives at a non-existent page.

You do it with a file called .htaccess.

If this file is present on your server, download it so that you don’t accidently overwrite the information already existing in it. If it doesn’t exist yet, good, you can safely create a new .htaccess file and add this line to it:

ErrorDocument 404 http://yourdomainname.com/404.php

Save the file and upload it to your root folder. You are done.