[squid-users] url_rewrite_program issue

From: xan <micci.adriano_at_gmail.com>
Date: Fri, 23 May 2014 03:08:52 -0700 (PDT)

Goodmorning all,
I'm pretty new to Squid and I would to make a simple url_rewrite_program.
The problem is that although all seems to work fine, the rewrite doesn't
work.

Here my tiny squid.conf:
/acl MyNetwork src 192.168.0.0/16
http_access allow MyNetwork
http_access deny all
http_port 3128
url_rewrite_program /etc/squid3/redirect.php/

Here my tiny redirect.php:
/#!/usr/bin/php
<?php

$temp = array();

// Extend stream timeout to 24 hours
stream_set_timeout(STDIN, 86400);

$var = fopen("debug_php.txt","a+");

while ( $input = fgets(STDIN) ) {
  // Split the output (space delimited) from squid into an array.
  $temp = split(' ', $input);

  // Set the URL from squid to a temporary holder.
  $output = $temp[0] . "\n";
  fwrite($var, $output);

  // Check the URL and rewrite it if it matches www.thisisawebsite.site
  if ( strpos($temp[0], "www.thisisawebsite.site") !== false ) {
    $output = "302:http://www.google.com/\n";
  }
  echo $output;
}
fclose($var);/

(redirect.php found here:
http://wiki.squid-cache.org/ConfigExamples/PhpRedirectors)
So although I didn't get any kind of error on the squid.log the script
doesn't rewrite. I forgot something?
My Squid version is 3.3.8 and my PHP version is 5.5.9-1ubuntu4 (cli)

I hope that someone can help me, thanks in advance.
Kind regards.
Xan

--
View this message in context: http://squid-web-proxy-cache.1019090.n4.nabble.com/url-rewrite-program-issue-tp4666083.html
Sent from the Squid - Users mailing list archive at Nabble.com.
Received on Fri May 23 2014 - 10:09:43 MDT

This archive was generated by hypermail 2.2.0 : Fri May 23 2014 - 12:00:06 MDT