I want to redirect all my http proxy traffic to a perl or php script.
I have a working squid setup, and have this in my squid.conf
url_rewrite_program "c:\\squid\\redirect.pl"
But when I start squid in the console it exists with abnormal program termination and this is in the cache.log:
2012/03/23 19:26:12| helperOpenServers: Starting 5 'c:\squid\php\redirect.pl' processes
2012/03/23 19:26:12| ipcCreate: CHILD: c:\squid\php\redirect.pl: (8) Exec format error
2012/03/23 19:26:12| ipcCreate: PARENT: OK read test failed
2012/03/23 19:26:13| --> read returned 4
Same happens with the PHP script. The scripts are working fine when I execute directly in the console.
Content of perl script:
#!/usr/bin/env perl
$|=1;
while (<>) {
$url = m/^([^ ]*)/;
if ($url !~ /^http:\/\/www\.hostname\.com/) {
$url =~ s@^http://www\.hostname\.com/(.*)@http://www.hostname.com/\1@;
print "301:$url\n";
} else {
print "$url\n";
}
}
enter code here