2017-07-24 81 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 
相關問題