Forum Moderators: phranque
ErrorDocument 403 http://www.example.com
ErrorDocument 404 http://www.example.com
I just wondered if anybody had any opinions as to whether the .htaccess approach is the most efficient/stable) way to acheive this and also whether as a principle if the redirection of 403/4s to the homepage is appropriate.
I would appreciate any feedback.
I just to confirm that I'm not going against any apache/web development conventions that I don't know about.
Cheers
[edited by: jatar_k at 3:08 pm (utc) on April 11, 2007]
[edit reason] please use example.com [/edit]
ErrorDocument 403 http://www.example.com
ErrorDocument 404 http://www.example.com .htaccess is one way to achieve this -- I don't know about whether it's the "most efficient/stable way," but it's certainly one of the better ways to do it, as compared to slower/less efficient scripting or some other alternative.
However, the code you've posted is incorrect, and will actually result in a 302 redirect, instead of returning the proper server 403/404 response codes. The correct way to write it is:
ErrorDocument 403 /
ErrorDocument 404 / This is well-described in the Apache core ErrorDocument documentation [httpd.apache.org], and I recommend a thorough read, especially of the notes at the end.
The use of the homepage as an error page is bad for several reasons. First, it may confuse the visitor. Second, it can lead to large duplicate-content issues, and negatively affect your ranking in search.
Each error should be handled by a page which describes the error in language suitable to your audience, and offers solutions such as links to your home page, category pages, and/or site map. You may also wish to ask visitors to report the problem if appropriate to your site's demographics, and if it offers any advantage to you.
Server response codes lie at the heart of proper Web operation, and I recommend that you pay very close attention to getting the details right at this level. Many 'mystery' site performance problems can be traced to bad implementations at this very basic level.
Server responses can be checked using the "Live HTTP Headers" extension to Firefox to make sure the response codes and all other details are correct.
Jim
Serve a custom page that tells the user that an error has occurred and then include a selection of site navigation to get the user clicking on their way towards the sort of content that they might have been looking for.
This page might be similar to your index page, perhaps a cut down version of it; but I would not be serving an exact rendition of the index page itself.
Justin