<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -T -w
#
# rredir.pl
#
# Author: Peter Eisenhauer &lt;pe@pipetronix.de&gt;
# First Version: 26. May 1997
#
# Description: Direct all request to files who are in a local dir to
# this directory
# 
use File::Basename;
use URI::URL;

# customization part

# Local Domainame from which no redirects should be done
$localdomain = 'pipetronix.de';
# Local domainame qouted for regexps
$regexlocaldomain = quotemeta($localdomain);
# Path under which the scripts accesses the local dir (must end with /)
$access_local_dir='/opt/utils/etc/httpd/htdocs/local-rredir/';
# Information for the redirected URL (redirect_path must end with /)
$redirect_scheme = 'http';
$redirect_host = 'ws-server.pipetronix.de';
$redirect_path = 'local-rredir/';

# end of customization part

# flush after every print
$| = 1;

# Process lines of the form 'URL ip-address/fqdn ident method'
# See release notes of Squid 1.1 for details
while ( &lt;&gt; ) {
    ($url, $addr, $fqdn, $ident, $method) = m:(\S*) (\S*)/(\S*) (\S*) (\S*):;

    $url = url $url;
    $host = lc($url-&gt;host);

    # do not process hosts in local domain or unqualified hostnames
    if ( $host =~ /$regexlocaldomain/ || $host !~ /\./ ) {
	next;
    }

    # just the file, without any host or path parts
    # and just in case: lowercase the file name, so you should make sure
    # all the files in the local dir are only lowercase !!
    $file = lc(basename($url-&gt;path));

    # look if in local dir, if yes redirect
    if ( $file &amp;&amp; -r $access_local_dir . $file
	&amp;&amp; $file ne '.' &amp;&amp; $file ne '..' ) {
	$url-&gt;scheme($redirect_scheme);
	$url-&gt;host($redirect_host);
	$url-&gt;path($redirect_path . $file);
    }

} continue {
    print "$url $addr/$fqdn $ident $method\n"
}
</pre></body></html>