Squid can be used to rewrite requested URL to another URL. The URL rewrite is done transparently without the browser knowing anything. Below is a very simple example of how to rewrite URL using squid using a Perl script.



use warnings;
use strict;

# "forces a flush right away and after every write or print on the currently selected output channel", see perldoc perlvar

while (<>) {
    my @inputs=split / /;

    if ($inputs[0] =~ q|http://checkwebcam\.com/main\.css|) {
        print 'http://localhost/mystyle.css'."\n";
    } else {
        print "\n";

Configure squid to call the rewriter script by adding this line to /etc/squid/squid.conf: [[!format ini """ url_rewrite_program /usr/local/bin/squid.rewriter.pl """]

For every request to http://checkwebcam.com/main.css, squid will not get http://checkwebcam.com/main.css instead squid will get http://localhost/mystyle.css and send the content back to the browser. Other request will be processed as usual.