我已经在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以便网址“ http://20.02.2.22/testsite1 &QUOT;会在内部转发到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>

其他提示

我展示本地测试站点的方式是动态DNS和端口转发的组合。

在内部,我的Drupal站点位于[我的机器ip]或localhost。

我为我的IP设置了一个免费的动态DNS名称,然后在我的路由器上,接受端口上的传入请求以路由到[我的机器ip]

通过这种方式,他们可以看到yoursite.dyndns.com,但它会查看您的本地副本。

为什么您不购买新域名并将其指向您的服务器IP地址... 或者有免费的域名解决方案,如:

http://www.dot.tk/en/index.html?lang=en
or
http://dyn.com/dns/

如果您想购买新域名,我建议您使用这个便宜优质的服务: http://server2.elite7hackers.us/recommend.php?site=godaddy

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top