域指向一台服务器,子目录指向另一台服务器

Domain pointing to one server with sub-directory pointing to another

我最近为客户开发了一个新网站,现在是时候上线了。但是,我遇到了一个问题:

所以,我需要一种方法将www.example.com指向新机器IP并指向www.example.com/proj 到旧机器IP。我该怎么做?

example.com 域的 DNS,更改记录以指向新 IP。然后在新服务器中,确保 mod_proxy 已打开,您可以将其添加到 server/vhost 配置:

ProxyPass /proj/ http://1.2.3.4/
ProxyPassReverse /proj http://1.2.3.4/

其中“1.2.3.4”是旧服务器的 IP 地址。

您可以在 htaccess 文件中使用 mod_rewrite 做类似的事情:

RewriteEngine On
RewriteRule ^proj/(.*)$ http://1.2.3.4/ [L,P]