Custom 404 Error Message Page
I was asked earlier by a friend how to create a custom 404 error page, So i figured i would write a small tutorial on it.
Why would i want a custom 404 error page?
The main reason for using a custom 404 error page is to add a little personality or humor to something that is, at the end of the day, a mistake on your part. Some people like to include a funny story about why the page is not there, Others prefer the heartfelt apology, But the main thing to include on this 404 error page is a link to your homepage, Which is something a regular 404 error page doesn't include.
First thing you need to do is instruct your server to use a specific page for your custom 404 error page instead of the usual boring page. We do this with an .htaccess file.
If you don't already have an .htaccess file in your root directory, Create one, Then put the following line into it.
ErrorDocument 404 http://www.domain.com/404-error-page.php
Change domain to your domain.
So now you know how to make your server display your custom 404 error message, What should we put on it? This is where your imagination comes in. It is a good idea to keep your error message lighthearted.. If you know PHP you could even make your 404 error message send you an email every time someone gets an error.
I believe a 302 status would be correct mark because the server has been instructed to serve the custom page instead of sending a 404 status.
The 302 status sends the visitor to your custom page whenever they request a page that doesn't exist.
I have never really thought about checking the status sent by a custom 404 error page, I'll look into it and post here if i find anything.
Posted by [ Matt ] @ Friday, 28 July, 2006
Good point Mark, I hadn't really though about that. My guess would be as long as you are not giving a 200 status (everything is ok) it should be fine.
This method of custom 404's has been used for a long time so i would be very surprised if it was able to get you penalized by search engines.
I will definately try to find a definitive answer on this though, I'lll post if i find it.
Posted by Anonymous @ Saturday, 29 July, 2006
Saw your post over at Matt Cutts' blog, and had to comment.
You need to change the entry in the .htaccess to:
ErrorDocument 404 /404-error-page.php
It seems that the relative link is important in the handling of the error in Apache.
We had a discussion here about it...
Post a Comment