Hi;
This is something that comes up more often than you'd expect, and lots
of people are in the dark about it, too, as all of those generic 404
pages show.
To do the kind of "intelligent" error handling you want, you need a
two step solution.
The first step is to edit your .htaccess file. You can find it at the
root of your site. If there is a an "ErrorDocument" directive in that
file, you need to change it. If there none, you have to add it. Full
documentation of this directive is in the Apache documentation at
http://httpd.apache.org/docs-2.0/mod/core.html#errordocument .
In most cases you'd add something like this:
ErrorDocument 404 /notfound.html
This would over-ride the generic message and send any missing page
urls to a page called "notfound.html" so that you could at least have
a page that matched the rest of your site and gave the user a few
options such as links to go to the site home page, search page or
whatever.
For the second step, to get "intelligent" error handling, the easiest
way to make it work is to point that ErrorDocument directive to a
script page. Depending on what scripting languages your server
configuration supports, you'd write a script that would capture parts
of the request url, and then redirects the user to a different url
based on what it captured.
For example, in PHP you'd have something like this embedded in the
page:
<?php
$theSearchString = getenv("REQUEST_URI");
Header("Location: http://www.thedomain.com/dbsearch.php?item=$theSearchString";
?>
This script would :
a) grab the part of the url after the domain slash and call it
theSearchString, and
b) redirect the browser to a new url, made up of the path to the
database search page and theSearchString .
(Note - In the real world, you'd probably will want to add some code
into this to make sure that you were only passing item numbers to that
search page, not merely misspelled page names. You would probably do
best to specify different processing for bad urls including the string
.html for example.)
In your situation, it appears that the .htaccess thing has been done,
and that there's a page already in place that is trying to do exactly
what I've just described. The error page shows the appropriate catalog
entry, but just adds an inappropriate page expired warning. Have a
look through the code of your error handling page, and I'll bet you'll
find a subtle error - like a case that is too broadly defined - in the
expired page module.
I hope this had been helpful, and that it hasn't been too tedious (but
you know how it goes when a geek gets rolling...)
All the best;
daveslipp-ga |
Clarification of Answer by
daveslipp-ga
on
23 May 2002 15:33 PDT
Are you trying to accomplish the same result without a script? i.e.
striclty within Apache?
If so, you can do it, but you'd need to write, build and install a
custom module in Apache to do it. The built in processing in Apache
isn't robust enough on its own to do the error checking that you'll
require.
I've seen people do this type of custom module porduction, but
normally they do it on a dare, to show off, or as part of a job where
they're being paid by the hour, since it takes so much longer to do
the module than the scripting solution.
|