PERL: Intelligent redirect

Jamie McCarthy jamie at mccarthy.org
Tue Mar 10 14:32:28 EST 1998


Roy Tennant wrote:

> ...if someone enters:
> 
> http://sunsite.berkeley.edu/govdata/info/
> 
> and the URL is actually
> 
> http://sunsite.Berkeley.EDU/GovData/info/

Your best solution may be to use Apache, if you aren't already,
and compile in mod_speling [sic].

<http://www.apache.org/docs/mod/mod_speling.html>

   This module is contained in the mod_speling.c file, and is not
   compiled in by default. It attempts to correct misspellings of
   URLs that users might have entered, by ignoring capitalization
   and by allowing up to one misspelling.  This catches the
   majority of misspelled requests.

> Rather than being sent to my static page for "when all
> else fails", they get the cryptic server-produced "404 Not Found" error,
> which is unacceptable.

Only thing I can think of -- stupid question, sorry -- are you 100%
certain that /errors/notfound.html is the name of your static page?

> I have tried to catch the fact that I've already been bounced once

Do you know that it bounces you more than once?  How do you know?

> by
> seeing if the HTTP_REFERER environment variable has the program name

Not the most reliable thing in the world...not all browsers pass an
appropriate HTTP_REFERER field.  Anyone going through the
Anonymizer, for example, won't send you one.  It looks like your
server sends you the failed URL in the QUERY_STRING somewhere, why not
check that to see if "notfound" is in there?

-- 
 Jamie McCarthy                 jamie at mccarthy.org


More information about the Web4lib mailing list