Apache:Two 主机指向相同的域
Apache:Two hosts pointed to same domains
我在同一台服务器上的两个单独的文档根目录下托管了两个网站。现在,这两个站点的 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>
我不知道是什么导致了这个问题。但是如果你为虚拟主机设置这个配置会发生什么:
# 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
我在同一台服务器上的两个单独的文档根目录下托管了两个网站。现在,这两个站点的 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>
我不知道是什么导致了这个问题。但是如果你为虚拟主机设置这个配置会发生什么:
# 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