我有一个通过路由器连接到互联网的计算机子网(也可能是一个HTTP代理)。
我的目标是更改一个URL的URL参数。
如果用户访问http://www.google.com/或访问http://www.google.com/?hl=zh-CN ,则两种情况下都应该看到http://www.google.com/的内容。 HL = FR
是否有可能在Apacheconfiguration中使用URL重写? 还有哪些方法可以成为实现这一目标的最简单的方法?
更新: google.com只是一个例子,事实并非如此。
您可以使用SQUID(更常用作代理)来完成您正在尝试的操作。 url_rewrite_program选项允许将请求发送到脚本进行重写。
以下脚本将replace您描述的庄园中的url:
#!/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 $_; } }
如果你喜欢使用apache,听起来可以用mod_proxy和mod_rewrite的组合来完成。 在apache.org上看到这个页面的教程。