别名不适用于 Apache2.4

rod*_*ker 2 alias apache2.4

我已从较早的 Apache2 升级到最新的 Apache 2.4。我之前的设置在 sites-available 目录中的 default.conf 文件中有以下别名:

Alias /weewx /home/weewx/public_html
<Directory "/home/weewx/public_html">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

在新的 Apache 2.4 设置中,我在站点可用的 000-default.conf 中添加了以下内容:

Alias /weewx /home/weewx/public_html

<Directory /home/weewx/public_html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
</Directory>
Run Code Online (Sandbox Code Playgroud)

但是现在我收到 403 错误 - “您无权访问此服务器上的 /weewx”。我曾尝试将我的新别名和目录条目移动到 mods-available 目录中的 alias.conf 文件中,但这仍然会出现 404 错误。

我的目录条目是否有问题,或者别名和目录是否位于错误的位置?

Flo*_*sch 6

你需要添加

Require all granted
Run Code Online (Sandbox Code Playgroud)

到您的新目录容器以授予对该目录的访问权限。这取代了旧的

Order allow,deny
Allow from all
Run Code Online (Sandbox Code Playgroud)

有关方面的更多信息,请参阅Apache 文档