You have all experienced it. You are on one of your favorite websites or blogs, when you click on a link that is broken or does not go anywhere and up comes the 404 error that webmasters everywhere dread. Most likely after the 404 error, you will see a lot of technical jargon that you do not understand and then will probably go back or exit out of the page.
If you want to keep visitors on your site longer, engages them, and offers to report the 404 issue, then setting up a special 404 error page is a must.
How nice would it be if a visitor to your blog landed on a 404 page that apologized to them, gave them some other links from your blog, and at the same time offered them a way to contact you to let you know that the page or post they are looking for is gone or broken?
Well, it is not very hard, so let’s learn how to do it!
The .htaccess File
Before you do anything, back up your .htaccess file. This will ensure that if you make a mistake, you can fix it.
You should have one in the directory of your site, but if you do not, then you will have to create it.
Go ahead and FTP into your web server and look at the directory that should have your web page files. The .htaccess will be contained where your home page document is located. Since it has a dot in the title, it should be somewhere near the top.
Time to Edit
Add this line to your .htaccess file:
ErrorDocument 404 http://www.domain.com/404page.html
That is all you have to add, just a single line of code.
Take note that where I have www.domain.com/404page.html, you will need to put the URL to your own 404 page. If you do not have one, go ahead and create one with everything you want on it.
Turn It On
If you had an .htaccess file already, then it should already be turned on. If you did not, you must turn it on. If you have a UNIX server, you will telnet into the server. Type this at the prompt:
chmod 664 .htaccess
If you do not run a UNIX server, then the file should already be ready to roll.
You Are Done!
Upload the 404 page you have created and you are ready to go. Go ahead and check it out. Go to a page that does not exist and you should see the page that you set in your .htaccess file as the new 404 page.
Of course, if you do not want to take the time to edit your .htaccess file, you can always use a plugin called AskApache Google 404 like I did. This custom 404 is search friendly and looks pretty nice.