我已经在一个 drupal 测试站点上工作了一段时间,它有一堆这样设置的虚拟主机:
<VirtualHost *:80>
ServerAdmin email@example.com
DocumentRoot "/path/to/root"
ServerName testsite1.example.com
</VirtualHost>
我一直在使用修改后的主机文件来查看这些测试站点中的每一个,按照以下行:
12.0.0.1 localhost 20.02.2.22 testsite1.example.com 20.02.2.22 testsite2.example.com 20.02.2.22 testsite3.example.com
这工作得很好,但是现在我需要将网站远程发送给一些人,他们的技术不足以修改他们自己的主机文件并按照我的方式查看它。
有没有一种方法可以设置 Apache,以便 url“http://20.02.2.22/testsite1”在内部转发到 testsite1.example.com?我正在使用 Drupal,站点设置需要查看“testsite1.example.com”,以便它可以正确选择要选择的实例。我一直在查看 apache 重写,但我对此有点陌生,所以非常感谢任何帮助。
最佳答案
testsite1.example.com 只会在您的机器上解析,因此您无法重定向。您可以使用 mod_proxy 设置代理。希望这对你有用:
<VirtualHost *:80>
ServerAdmin email@example.com
DocumentRoot "/path/to/root"
ServerName testsite1.example.com
ServerAlias 20.02.2.22
<Location /testsite1/>
ProxyPass http://testsite1.example.com/
</Location>
</VirtualHost>
关于apache - 将内部路径重定向到虚拟主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/619174/