繁体   English   中英

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

[英]Request to apache2 server always redirects to /var/www (Index of /) site

我目前正在尝试按照DigitalOcean 上的本教程设置虚拟主机。

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

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

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

本页索引 .

这与我直接访问服务器 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/中还有一些其他文件夹,因为我租用服务器的公司预装了一些维护站点,但在这种情况下这无关紧要。 (请参阅编辑,这确实很重要)。

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

编辑:

很明显,我遗漏了另外 2 个默认启用的站点。 一个有以下内容:

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

很明显,我遗漏了另外 2 个默认启用的站点。 一个有以下内容:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM