Redirect html->cgi?

lydia lydia at sylvia.harvard.edu
Tue Aug 25 17:51:56 EDT 1998


Many thanks to all who suggested approaches to this problem. A number
of people wrote to tell me that my original strategies (ScriptAlias
and Redirect) should both work, either in an .htaccess file or in
httpd.conf, and a few suggested using mod_rewrite. The fact that all
of these still don't work for me shall remain, I'm afraid, a local
configuration mystery.

The solution I've decided to adopt actually turns out to be far
neater, for our purposes, than any of the the above. The suggestion
came from Roy, and I'm reprinting it here with his permission in case
there are others who may find this helpful. With just a quick loop in
our existing 404.cgi script, and a single new cgi script containing a
hash of info about the relevant filename changes, we can produce any
number of customized redirect pages with only one new script to
maintain, yet leave all of our webserver configuration completely
untouched. 

Thanks, Roy.  :)

-----
On Thu, 20 Aug 1998, Roy Tennant wrote:
>
> I do this kind of thing the following way:
> 
> 1) write a Perl program to handle your 404 not found errors
> 2) edit your server configuration file to point to that program (e.g.,
> nph-notfound.cgi) instead of a static error message file or (god forbid)
> the default server error message
> 3) edit the program to filter requests for the "moveme.html" file and
> automatically forward users to the program you want to execute.
> 4) remove the "moveme.html" file to cause 404 errors when it is requested.
> 
> Since this kind of thing is probably best seen rather than explained, I've
> set up an alias that will display my server's program to you. You should
> know that I've set it up to use "non-processed headers", which is why the
> filename is prefaced with "nph-". That allows me to send the client a

> "HTTP/1.0 301 Document has moved" message before redirecting them.
> 
> You can take a look at the program at:
> 
> http://sunsite.Berkeley.EDU/~manager/Software/nph-notfound.txt
> 
> you will notice it is mostly a series of if/then/else statements to look
> at what they requested and when a match is found, route them to the
> appropriate place. When this happens, the user is none the wiser.
>
> Roy Tennant





More information about the Web4lib mailing list