|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/usr/share/doc/squid-2.5.STABLE14/ |
Upload File : |
#!/usr/bin/perl -T -w
#
# rredir.pl
#
# Author: Peter Eisenhauer <pe@pipetronix.de>
# 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 ( <> ) {
($url, $addr, $fqdn, $ident, $method) = m:(\S*) (\S*)/(\S*) (\S*) (\S*):;
$url = url $url;
$host = lc($url->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->path));
# look if in local dir, if yes redirect
if ( $file && -r $access_local_dir . $file
&& $file ne '.' && $file ne '..' ) {
$url->scheme($redirect_scheme);
$url->host($redirect_host);
$url->path($redirect_path . $file);
}
} continue {
print "$url $addr/$fqdn $ident $method\n"
}