我已经使用 mod_proxy 和 mod_proxy_http 将我的 apache 2.2 服务器配置为简单的转发代理。
当客户端请求以下格式的 URL 时:
http://specific.host.com/specific?specificarg1=(.+)&specificarg2=(.+)&specificarg3=specificvalue
以重写的形式请求,其中specificarg1和specificarg2的值被我的服务器配置中定义的值替换。
也可以不使用正则表达式,而是将特定的 url 重写为另一个特定的 url,但我更喜欢使用正则表达式匹配。
因此,在阅读了 mod_rewrite、mod_proxy 的文档之后,我尝试了以下类似的方法来完全实现某种重写:
RewriteRule .* http://www.google.com/ [P,L
]
就像在服务器配置中一样,通过代理浏览时没有任何内容被重写
<VirtualHost *:80>
ServerName domain-i-tried-to-surf-to.com
`RewriteRule .* http://www.google.com/ [P,L]
</VirtualHost>
也没有运气
ProxyPass(Reverse) / http://www.google.com
ProxyPass(Reverse) /path/i/tried/to/surf/to http://www.google.com
也没有运气
ProxyRemote * http://www.google.com
也没有运气
我还尝试将重写规则放入代理匹配指令中,但我无法重写 url。有人可以指出我正确的方向吗?