Mod_rewrite 反向代理,从另一个网站提供内容

Mod_rewrite proxy reverse, serve content from another website

我会尽力向您解释我想做什么:

我有我的本地网站 http://localhost/(WAMP 服务器) 我有另一个网站 http://domain.com/

我想设置一个 mod_rewrite 规则,可能会使用 proxyreverse,这样所有对 localhost 的请求都会发送到 domain.com 并从 localhost 返回,而不使用任何 301 重定向。

例如: http://localhost/ 应该呈现 http://domain.com/ 的内容 http://localhost/index.php?id=1 should render the content of http://domain.com/index.php?id=1

如果可能的话,我希望也通过所有 header、get 和 post。

我试过了,但没有成功,在 google:

上找不到任何东西

ProxyPass / http://localhost/domain/ ProxyPassReverse / http://domain.com/

我也尝试过此 link 中的教程,但它确实将我重定向到 domain.com 而这不是我想要的 http://httpd.apache.org/docs/current/rewrite/proxy.html

PS: mod_rewrite、mod_proxy 和 mod_proxy_http 已激活。

谢谢

您可以使用 mod-rewrite 的 P(代理)标志:

RewriteEngine on

RewriteRule ^ http://example.com%{REQUEST_URI} [P]

这会将来自您域的所有请求内部转发到 example.com。