Forum Moderators: phranque

Message Too Old, No Replies

Redirecting 404 error page to homepage?

Is this a good idea or not?

         

riospace

4:07 am on Nov 19, 2006 (gmt 0)

10+ Year Member



I have noticed that some sites redirect there 404 error pages to their homepage. Is this a good idea? If so, what kind of redirect should be used to do this?

jonrichd

12:16 pm on Nov 19, 2006 (gmt 0)

10+ Year Member



You can use the errordocument directive in your .htaccess file to specify a file to display in case of a file not found error. You can use the home page, or another file if you like. This works for Apache/Unix servers. If you are using Windows hosting, you pretty much can only do this if you have access to the IIS control panel.

As to whether the home page is the best place to redirect to, it probably depends on the size of your website and the number of 404 errors it typically generates. The end-user doesn't realize that they are getting to your home page because of a 404 error, so they could become confused. That's why many sites have a page that explains that the file wasn't found, and include a mini site map to popular areas so the user might be able to find what he/she wanted.

In this case, your logs can be your friend. Look for the 404 errors in your logs to see if there are any real patterns. If you see a lot of requests for one specific file, perhaps from an external link to old content, consider creating a page to replace it (or see if there is already one on your site that matches the theme of the old file, and do a 301 redirect for it specifically).

In any case, make sure that if you set up a custom error page, it actually returns the proper 404 response to the browser/spider using a server header checker. If you return a 200 or a 302, you risk a duplicate content penalty.

phranque

5:07 pm on Nov 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



since i heard this mentioned by several esteemed speakers at pubcon i will reinforce/paraphrase jonrichd:
MAKE SURE YOUR CUSTOM 404 ERROR PAGE ACTUALLY SERVES A CODE 404 WITH THE PAGE!

ktalk

8:42 pm on Nov 21, 2006 (gmt 0)

10+ Year Member



Can you explain how the above can be done? I was under the impression that you don't need to do anything like that?

phranque

7:53 am on Nov 29, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



answering ktalk's?:

Can you explain how the above can be done? I was under the impression that you don't need to do anything like that?

the reason you want a 404 status is to tell the search engines that content was not found.
otherwise they will be satisfied using your custom "404 error page" as content since it actually returned a 200 OK status.

according to the HTTP/1.1 specification (http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html),
the very first line of an http response message is the status line.
in this case you would use


HTTP/1.1 404 Not Found

the trick is finding out where this line is actually being generated for your server.