域被重定向到同一滴中的另一个域
问题描述:
嗯,我是Debian上的新成员,使用Debian OS在Digital Ocean上构建服务器。 我成功添加两个域成一个液滴:域被重定向到同一滴中的另一个域
mysite.com
anothersite.com
创建新的目录:
/home/user/www/mysite.com/public_html
并复制文件到public_html
内/etc/apache2/sites-available
配置文件是:
DocumentRoot /home/user/www/mysite.com/public_html
<Directory /home/user/www/mysite.com/public_html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/myproject-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined
当然,我启用了该网站。
我还没有编辑apache2.conf
文件,并没有配置第二个域(anothersite.com
)。只需将第二个域添加到液滴即可。
当我进入该网站mysite.com
它的作品完美。但我想知道为什么第二域(anothersite.com
)被重定向到第一域(mysite.com
)?
顺便说一句,我使用Apache 2.4
答
如果主机名(如anothersite.com)指向Apache网络服务器,但并没有明确地配置相匹配的主机名,则Apache会提供一个“最佳匹配一节“ (首先 )。
所以如果只有一个在apache配置中并且多个主机名(mysite.com和anothersite.com)指向同一台机器,所有这些名称都将显示相同的虚拟主机