对apache2服务器的请求始终重定向到/ var / www(/的索引)站点

我目前正在尝试按照此tutorial on DigitalOcean设置虚拟主机。

我要提供服务的虚拟站点位于/var/www/example/html/index.html下。我尚未注册官方域,但设置/etc/hosts/来将example.com解析为服务器的IP地址。

我在example.conf下创建了另一个名为/etc/apache2/sites-available的conf文件,并用sudo a2ensite example.conf启用了该文件,并禁用了000-default.conf

现在,每当我在浏览器中转到example.com时,我都会得到服务:

对apache2服务器的请求始终重定向到/ var / www(/的索引)站点

这是直接进入服务器IP地址时将获得的同一页面。仅当我直接到达example.com/example/html时,我才能得到正确的index.html

我当前的配置如下:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我在笔记本电脑上的/etc/hosts文件是这样的:

#<ip-address>   <hostname.domain.org>   <hostname>
<server-ip> example.com

/var/www/中还有一些其他文件夹,因为我从其租借服务器的公司已预先安装了一些维护站点,但是在这种情况下这无关紧要。 (请参见编辑,这确实很重要)。

感觉好像我在这里遗漏了一些明显的东西,但是我找不到解决问题的方法。

编辑:

我很想念的事情是,默认情况下也启用了另外两个站点。 其中一个具有以下内容:

# 10_froxlor_ipandport_<ip-address>.conf
# Created 28.11.2019 21:05
# Do NOT manually edit this file,all changes will be deleted after the next domain change at the panel.

<VirtualHost <ip-address>:80>
DocumentRoot "/var/www/"
 ServerName <predefined Server name>
</VirtualHost>

在禁用所有其他站点之后,对example.com的请求实际上转到了右边的index.html

我认为,上述启用的站点实际上与我的浏览器发出的请求匹配,并显示了www根目录。

lawdragon 回答:对apache2服务器的请求始终重定向到/ var / www(/的索引)站点

我很想念的事情是,默认情况下也启用了另外两个站点。 其中一个具有以下内容:

# 10_froxlor_ipandport_<ip-address>.conf
# Created 28.11.2019 21:05
# Do NOT manually edit this file,all changes will be deleted after the next domain change at the panel.

<VirtualHost <ip-address>:80>
DocumentRoot "/var/www/"
 ServerName <predefined Server name>
</VirtualHost>

在禁用所有其他站点之后,对example.com的请求实际上转到了右边的index.html

我认为,上述启用的站点实际上与我的浏览器发出的请求匹配,并显示了www根目录。

本文链接:https://www.f2er.com/3011040.html

大家都在问