假设我有exampleA.com和exampleB.com。 如果我想在Apache Web服务器上重写一个Apache Web服务器到websiteB.com,就像当我在浏览器中inputexampleA.com时一样,它将保留这个URL并显示加载的内容,就像我正在导航到exampleB.com,我怎样才能做到这一点直接虚拟主机添加?
我的研究表明:
RewriteRule /some/url(.*) http://exampleB.com/some/url$1 [P,L]
但是我不熟悉的是“/ some / url”部分的相关性,因为我不想只重写特定的URI,而是整个域。
同样,如果我导航到exampleA.com/test.htm,它应该呈现任何在exampleB.com/test,浏览器说“exampleA.com/test”整个时间。
为了使这个规则适用于整个域,你会想..
RewriteRule /(.*) http://exampleB.com/$1 [P,L]
这基本上是一样的东西:
ProxyPass / http://exampleB.com/
请记住,有很多事情可能将用户的浏览器指向exampleB
域。 ProxyPassReverse
将处理30x
redirect:
ProxyPassReverse / http://exampleB.com/
但内容中的其他内容可能指向exampleB.com
,包括HTML内容(可能会帮助mod_proxy_html
),JavaScript,CSS等。
你不能。
如果你想保留原始的URL,你需要通过examplea实际代理(查找ProxyPass)exampleb或者使用某种forms的框架shenanigans。