Apache:两台主机指向相同的域
Posted
技术标签:
【中文标题】Apache:两台主机指向相同的域【英文标题】:Apache:Two hosts pointed to same domains 【发布时间】:2017-12-30 04:07:16 【问题描述】:我在同一台服务器上托管了两个网站,位于两个单独的文档根目录下。现在,这两个站点的 URL 已在域级别更改(这是由第三方完成的)。现在,问题似乎是两个 URL 都链接到同一个网站。问题可能出在哪里?
虚拟主机是这样说的:
NameVirtualHost 123.123.123.124:80
<VirtualHost 123.123.123.124:80>
ServerName www.test.com
DocumentRoot "/path/to/document/root/"
<Directory "/path/to/document/root/">
php_admin_flag engine on
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>
NameVirtualHost 123.123.123.124:80
<VirtualHost 1123.123.123.124:80>
ServerName www.test2.com
DocumentRoot "/path/to/document/root/"
<Directory "/path/to/document/root/">
php_admin_flag engine on
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
DirectoryIndex index.html index.php
</Directory>
</VirtualHost>
【问题讨论】:
你能发布你的设置代码吗? 您是否使用了两个不同的虚拟主机来监听不同的端口? @JoelStüdle 虚拟主机配置已添加到帖子中。谢谢 【参考方案1】:我没有正确的想法是什么导致了问题。但是如果您为虚拟主机进行此配置会发生什么:
# try it with the asterisks in front of :80
# are you shure 123.123.123.124 is the ip you need?
NameVirtualHost *:80
# setup for test.com
<VirtualHost *:80>
ServerName www.test.com
DocumentRoot /path/to/document/test/
</VirtualHost>
<Directory "/path/to/document/test/">
php_admin_flag engine on
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
DirectoryIndex index.html index.php
</Directory>
# setup for test2.com
<VirtualHost *:80>
ServerName www.test2.com
DocumentRoot /path/to/document/test2/
</VirtualHost>
<Directory "/path/to/document/test2/">
php_admin_flag engine on
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
DirectoryIndex index.html index.php
</Directory>
如果您对 vhost 配置进行了更改,请不要忘记重新启动 apache 服务器!
# macintosh
sudo apachectl restart
# linux
sudo service apache2 restart
# windows
# sorry i do not know :D
【讨论】:
以上是关于Apache:两台主机指向相同的域的主要内容,如果未能解决你的问题,请参考以下文章