1     #!/usr/bin/perl -Tw
2     use strict;
3     print STDERR
4       join (" ",
5             map "[$_]",
6             scalar localtime,
7             "404 ERROR",
8             map { $ENV{$_} || "-" }
9             qw(REDIRECT_URL REMOTE_HOST HTTP_REFERER)), 
10      "\n";
11    my $red_url = $ENV{REDIRECT_URL} || "?unknown?"; 
12    eval {
13      if ($red_url =~ /^\/~.*/s) { 
14        my $html = $red_url;
15        $html =~ s/[\x00-\x20"<&>"\x80-\xff]/&\#@{[ord$&]}\;/g; 
16        my $tp_html = "http://www.teleport.com$html";
17        print <<DQ;
18    Content-type: text/html
19    Status: 404 Not Found
20    
21    <HEAD><TITLE>File Not found</TITLE></HEAD> 
22    <BODY><H1>File Not found</H1>
23    The requested URL $html was not found on this server.<P>
24    Perhaps you were looking for something at Teleport's web-server, 
25    such as <A HREF="$tp_html">$tp_html</a>?
26    </BODY>
27    DQ
28        exit 0;
29      }
30    };
31    print <<"DQ";
32    Content-type: text/html
33    Status: 404 Not Found
34    
35    <HEAD><TITLE>File Not found</TITLE></HEAD> 
36    <BODY><H1>File Not found</H1>
37    The requested URL $red_url was not found on this server.<P>
38    Try looking at the <a href="http://www.stonehenge.com/">home page</a>. 
39    <!-- This is a custom message. -->
40    </BODY>
41    DQ