Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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\\"

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\' processes
2012/03/23 19:26:12| ipcCreate: CHILD: c:\squid\php\ (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
while (<>) {
  $url = m/^([^ ]*)/;
  if ($url !~ /^http:\/\/www\.hostname\.com/) {
    $url =~ s@^http://www\.hostname\.com/(.*)@\1@;
    print "301:$url\n";
  } else {
    print "$url\n";
enter code here
share|improve this question
up vote 1 down vote accepted

From :

Squid doesn't know how to run external helpers based on scripts, like .bat, .cmd, .vbs, .pl, etc. So in squid.conf the interpreter path must be always specified, for example:

url_rewrite_program c:/perl/bin/perl.exe c:/squid/libexec/

share|improve this answer
So simple! I had added the complete path to php.exe, but encapsuled it with quotes. Without the quotes it is working. thnx – Rutger van Baren Apr 3 '12 at 14:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.