How to Implement Redirects in Squid
Write a simple redirector program such as the following using Perl: #!/usr/bin/env perl $|=1; while () { $url = m/^(*)/; if ($url !~ /^http:\/\/www\.hostname\.com/) { $url =~ s@^http://www\.hostname\.com/(., In your squid.conf file change the...
Step-by-Step Guide
-
Step 1: Write a simple redirector program such as the following using Perl: #!/usr/bin/env perl $|=1; while (<>) { $url = m/^(*)/; if ($url !~ /^http:\/\/www\.hostname\.com/) { $url =~ s@^http://www\.hostname\.com/(.
*)@http://www.hostname.com/\1@; print "301:$url\n"; } else { print "$url\n"; } } -
Step 2: In your squid.conf file change the redirect_program variable
,, You'll need to know the path to the squid executable.
Depending on your operating system and installation, it's most likely at /usr/local/squid/sbin/squid.
Execute this command on the terminal: /usr/local/squid/sbin/squid
-k reconfigure -
Step 3: it's probably commented out
-
Step 4: and specify where your redirector_program is
-
Step 5: ex: /usr/sbin/redirect.pl
-
Step 6: Make sure that the variable httpd_accel_uses_host_header is set to on or nothing will be redirected.
-
Step 7: Reload the squid configuration.
Detailed Guide
*)@http://www.hostname.com/\1@; print "301:$url\n"; } else { print "$url\n"; } }
,, You'll need to know the path to the squid executable.
Depending on your operating system and installation, it's most likely at /usr/local/squid/sbin/squid.
Execute this command on the terminal: /usr/local/squid/sbin/squid
-k reconfigure
About the Author
Gloria Ward
Committed to making pet care accessible and understandable for everyone.
Rate This Guide
How helpful was this guide? Click to rate: