You can use SQUID, which is a more commonly used as a proxy, to accomplish what you are attempting. The url_rewrite_program
option allows for requests to be sent to a script for rewriting.
The following script would substitute the url in the manor you describe:
#!/usr/bin/perl
while (<>) {
@line = split;
$_ = $line[0];
if (m|http://google.com/\?hl=en|) {
# do some replacement work
$_ =~s|\?hl=en|\?hl=fr|g;
print $_,"\n";
} else {
# send the request directly
print $_;
}
}
If you prefer to use apache, it sounds like it can be done with a combination of mod_proxy
and mod_rewrite
. See this page on apache.org for a tutorial.