Time for action – writing a simple URL redirector program
Let's see a very simple Perl script that can act as a URL redirector program.
$|=1;
while (<>) {
s@http://www.example.com@303:http://www.example.net@;
print;
}The previous code is a URL redirector program in its simplest form. It redirects all URLs containing the URL www.example.com to www.example.net without inspecting values of any of the fields by Squid.
What just happened?
We have just seen a simplistic Perl script which can act as a URL redirector program and can be used with Squid.
Have a go hero – modify the redirector program
Modify the previous URL redirector program so that all requests to google.co.uk can be redirected to google.com.
Concurrency
We can make our URL redirector programs concurrent for better performance. When we configure Squid to use a concurrent URL redirector program, it passes an additional field, ID, on the standard input to the redirector program. This is used to achieve concurrency as we learned...