Re: [squid-users] replace gif with local gif

From: Michael Alger <squid_at_mm.quex.org>
Date: Sun, 20 Jul 2008 00:33:18 +0800

On Sat, Jul 19, 2008 at 09:24:22PM +0800, Adrian Chadd wrote:
> You should talk to whoever looks after jesred.

For jesred, you add a rule that looks like:

regex ^http://www\.google\.com/intl/en_ALL/images/logo\.gif$ http://www.yoursite.com/image.gif

or if you want to be fancy and catch all Google domains and
internationalisted images, something like:

regex ^http://(www\.)?google\.[^/]+/intl/.*/images/logo\.gif$ http://www.yoursite.com/image.gif

might work.

Note that if you're modifying the default jesred.rules file, you'll
probably have some lines like these:

abort .gif
abort .jpg

This tells jesred to stop processing the rules if it encounters a
request which ends with either of those extensions, so you should
put your Google-logo-rewriting rule before those or it'll never be
seen.

> But basically, you want to write a URL rewrite helper which does
> something like:
>
> #!/usr/bin/perl -w
>
> use strict
>
> # I think this means "line-buffered" .. :)
> $| = 1;
>
> while (<>) {
> s/http:\/\/www.google.com/logo.gif/http:\/\/www.yoursite.com/image.png/;
> print;
> }

I prefer to use a different separator character when doing
substitutions on URLs, to avoid having to escape all the slashes:

     s#http://www\.google\.com/logo\.gif#http://www.yoursite.com/image.png#;

(Also, you missed two /'s. :)
Received on Sat Jul 19 2008 - 16:33:23 MDT

This archive was generated by hypermail 2.2.0 : Sun Jul 20 2008 - 12:00:05 MDT