鱿鱼与PHP或Perl的“url_rewrite_program”在Windows上

我想将所有的HTTP代理stream量redirect到perl或php脚本。

我有一个工作的鱿鱼设置,并在我的squid.conf中

url_rewrite_program "c:\\squid\\redirect.pl" 

但是当我在控制台中启动squid时,它存在exception程序终止 ,这是在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 

PHP脚本也一样。 当我直接在控制台中执行时,脚本工作正常。

perl脚本的内容:

 #!/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 

http://wiki.squid-cache.org/KnowledgeBase/Windows

Squid不知道如何运行基于脚本的外部助手,比如.bat,.cmd,.vbs,.pl等等。所以在squid.conf中必须指定解释器path,例如:

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