Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created March 17, 2017 21:20
Show Gist options
  • Save peter279k/a9bbaf38242346c22328ce6d68a9b719 to your computer and use it in GitHub Desktop.
Save peter279k/a9bbaf38242346c22328ce6d68a9b719 to your computer and use it in GitHub Desktop.
PHPRedirect helper for squid proxy server.
#!/usr/bin/php
# Squid URL Rewrite program : Codes picked from the internet.
<?php
$temp = array();
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";
// Clean the Requesting IP Address field up.
$ip = split('/',rtrim($temp[1], "/-"));
if (preg_match("/^http:\/\/www.animen.com.tw/i", $temp[0])) {
$output = "301:https://www.google.com.sa/\n";
}
echo $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment