Received: by taz.hyperreal.com (8.7.6/V2.0) id LAA21782; Thu, 7 Nov 1996 11:42:53 -0800 (PST) Received: from nora.pcug.co.uk by taz.hyperreal.com (8.7.6/V2.0) with SMTP id LAA21768; Thu, 7 Nov 1996 11:42:43 -0800 (PST) Received: from imdb.demon.co.uk by nora.pcug.co.uk id aa27481; 7 Nov 96 18:49 GMT Message-Id: <199611071849.SAA03201> Subject: Re: Free missing_handler.pl script for Apache To: chris@dragonware.com Date: Thu, 7 Nov 1996 18:49:26 +0000 (GMT) In-Reply-To: <32822751.5AFC@dragonware.com> from "Chris Roberts" at Nov 7, 96 11:15:56 am From: Rob Hartill Organization: Internet Movie Database Reply-To: robh@imdb.com X-pgp-public-key: http://us.imdb.com/pgp.html X-Mailer: ELM [version 2.4 PL24 ME8a] Content-Type: text Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com Hi Chris, Thanks for the code. I'm not sure if we'll be able to use it as we're not too keen on distributing CGI.. it's been known to come back and haunt us. I'll pass the code on to the developers list to give it a fair chance. cheers, rob -=-=-=-=-=-==-=-=-=-=-= Chris Roberts wrote: > >The following perl scrip I wrote an I offer it as a free part of the >next apache distribution it is a quick hack but it works quite well and >is low impact on the cpu. > > >Chris Roberts >CEO/Programer >DragonWare Internet Solutions > >We run Apache and have activated the missing page handler directive in >the srm.conf file and have the following perl script installed in >cgi-bin/. > >------------------------------------cut >here----------------------------- > > >#!/usr/bin/perl >#file: missing_handler.pl >#Author: Chris Roberts >#Date: 06-10-1996 >#REV: 2.01 > >#This Script gets a missing page request and forwards it to a new >location >#or displays an error message with the refering page! ># > >&initIt; >&mainProg; >exit(0); > > >sub initIt{ ># >#change this to your web master's email address note the "\@\" must be >in place! ># >$webmaster="www\@\dragonware.com"; ># ># change the $redirectFile path as needed no other configuration is >needed. ># >$redirectFile="/usr/local/etc/httpd/cgi-bin/redirect.dbf"; ># >#redirect.dbf file format ># /directory/ (tab) http://www.fully.layed.out.domain/dir/ (tab)(cr) ># >#Note: The Perl Script redirectit.pl can manage this file via the web. >#Purchase it from DragonWare internet solutions for $50 USD >#sales@dragonware.com http://www.dragonware.com/ ># >$fromUrl=$ENV{'HTTP_REFERER'}; >$missingUrl=$ENV{'REDIRECT_URL'}; >$newUrl=$ENV{'SERVER_NAME'}; >$newUrl="http://".$newUrl; >$serverBase=$newUrl; >#un-comment for debug >#print "Content-type: text/html\n\n"; >#print "From :$fromUrl
"; >#print "URL Called $missingUrl
"; >#print "NEW URL $newUrl
"; >} > > >sub mainProg{ >#if a missing url matches the list >#call the redirectIt routine with the $newUrl >open(URLSET, "$redirectFile") || print "Error opening $redirectFile >file."; >while(!eof(URLSET)) >{ > $buffer = ; >($redirectUrl, $newUrl) = split(/\t/,$buffer); > if( $missingUrl eq $redirectUrl ) > { > close(URLSET); > &redirectIt; > return; > } > } > close(URLSET); >¬Here; >} > >sub notHere{ >print "Content-type: text/html\n\n"; >print"\r >\r > This File can not be found! \r >\r >

This URL $serverBase$missingUrl Can't be located


\r >

Please contact the WebMaster of the refering URL
\r > $fromUrl and tell of the inaccurate link.

\r >
\r >Your Webmaster\r >\n"; >} > >sub redirectIt{ >print "Status: 302 Moved Permanently\r >Location: $newUrl\r\n\r\n"; >print "Content-type: text/html\n\n"; >print "This resource has moved\r >

This resource has moved

\n"; >print "the url $missingUrl has moved to href=$newUrl>$newUrl"; > >------------------------------ cut here -------------------------------- >Change the srm.conf as follows > > ># 2) local redirects >#ErrorDocument 404 /missing.html ># to redirect to local url /missing.html > > >ErrorDocument 404 /cgi-bin/missing_handler.pl > > ># n.b. can redirect to a script or a document using >server-side-includes. ># ># 3) external redirects >#ErrorDocument 402 http://other.server.com/subscription_info.html ># > >and it works! > >please advise if this can be used in the Apache distribution the script >is avalible via anon ftp at: > >ftp://dragonware.com/pub/missing_handler.pl > >Chris > -- Rob Hartill. Internet Movie Database Ltd. http://www.imdb.com/