httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Hartill <r...@imdb.com>
Subject Re: Free missing_handler.pl script for Apache
Date Thu, 07 Nov 1996 18:49:26 GMT

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<br>";
>#print "URL Called $missingUrl <br>";
>#print "NEW URL $newUrl<br>";
>}
>
>
>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 = <URLSET>;
>($redirectUrl, $newUrl) = split(/\t/,$buffer);
> if( $missingUrl eq  $redirectUrl )
>   {
>   close(URLSET);
>   &redirectIt;
>  return;
>   }
>  }
>  close(URLSET);
>&notHere;
>}
>
>sub notHere{
>print "Content-type: text/html\n\n";
>print"<html>\r
><head>\r
><title> This File can not be found! </title>\r
></head>\r
><center><h1>This URL $serverBase$missingUrl Can't be located </h1><br>\r
><h2>Please contact the WebMaster of the refering URL<br>\r
><a href=$fromUrl> $fromUrl</a> and tell of the inaccurate link.</h2>\r
><hr>\r
><a href=mailto:$webmaster>Your Webmaster</a>\r
></body></html>\n";
>}
>
>sub redirectIt{
>print "Status: 302 Moved Permanently\r
>Location: $newUrl\r\n\r\n";
>print "Content-type: text/html\n\n";
>print "<html><head><title>This resource has moved</title></head>\r
><body bgcolor=FFFFFF><h1>This resource has moved</h1>\n";
>print "the url $missingUrl has moved to <a
>href=$newUrl>$newUrl</a></body>";
> 
>------------------------------ 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/  

Mime
View raw message