All web sites move pages to new locations, pages are removed from sites because they are old or outdated, visitors sometimes type the wrong URL to get to a page and I think I can list about 10 other reasons for users to end up with a 404 Page Not Found error. If you haven’t done anything with your hosting account all those visitors will just see the standard error page which is really boring and not helpful at all. On most hosting accounts you can do something about that and also earn some money from it!
Start by creating a text file called .htaccess in your web directory (that’s where you keep your main index.html or index.php file). I use Notes or Wordpad to edit my .htaccess files (or nano if I’m connected directly to the server).
The file should look something like this:
ErrorDocument 404 /404.php
If you already got a file called .htaccess in your hosting account you should simply just add the above line of text into that file (don’t over-write your existing .htaccess file since it may contain important information).
Now create a new file called 404.php (you can of course name the file anything you like, but I used 404.php in my .htaccess file so that’s what I’m going to use). You can use Notes or Wordpad for this file too. Fill in the following text in your new 404.php file:
<?
Header("HTTP/1.0 404 Not Found");
?>
<!-- Page content goes here -->
At <!– Page content goes here –> you simply add some text telling the visitor that the requested page wasn’t found on your server. Also give the visitor some advice on how to find the requested information (give the visitor a possibility to search your site for example of add a link to a site map).
Since the visitor is at your site he must be interested in your products or services, so don’t forget to tell the visitor about your products and services. Next time when a users see the 404 error page he will hopefully stay at your site a little bit longer instead of using the back-button in the browser immediately the 404 error shows up. Not everyone will become your customers, but at least enough for this to pay off