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

问题描述 投票:0回答:1

我目前正在尝试根据此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,我都会得到服务:

this Index of page

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

我当前的配置如下:

<VirtualHost *:80>
    ServerAdmin [email protected]
    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根目录。

apache debian webserver virtualhost document-root
1个回答
0
投票

我不知道的明显事情是,默认情况下也启用了另外两个站点。其中一个具有以下内容:

# 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根目录。

© www.soinside.com 2019 - 2024. All rights reserved.