2017-07-24 43 views
-3

我有两个网站托管在同一台服务器下两个单独的文档根。现在,这两个网站的网址已在域级别上更改(由第三方完成)。现在,问题出现,这两个网址都链接到同一个网站。问题在哪里呢?Apache:两台主机指向相同的域

这是虚拟主机这样说:

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> 
+0

你能发布你的设置代码吗? –

+0

你使用两个不同的虚拟主机在不同的端口上侦听吗? –

+0

@JoelStüdle虚拟主机配置添加到帖子。谢谢 – iqbalmp

回答

0

我没有正确的想法是什么原因造成的问题。但如果你把这个配置的虚拟主机会发生什么:

# 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> 

如果您更改虚拟主机的配置不要忘了重新启动Apache服务器!

# macintosh 
sudo apachectl restart 

# linux 
sudo service apache2 restart 

# windows 
# sorry i do not know :D 
相关问题