Как запретить доступ к подкаталогу в Apache 2.4, используя apache2.conf?

У меня есть установка по умолчанию Apache2 (2.4) на Ubuntu Server 18.04 с MySQL и PHP. Я не настроил никаких виртуальных хостов.

Я поместил файлы в / var / www, которые я хочу обработать, но мне нужно запретить доступ к / var / www / files. Вот соответствующий раздел из /etc/apache2/apache2.conf

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory "/">
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory "/usr/share">
        AllowOverride None
        Require all granted
</Directory>

<Directory "/var/www">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

<Directory "/var/www/files">
        Require all denied
</Directory>

var / www / files по-прежнему доступен для просмотра и имеет хороший список каталогов. Почему <Directory "/var/www/files"> Быть игнорированным?

Если я изменю раздел / var / www с Require all granted в Require all denied, что сводит весь сайт вниз, как и ожидалось.

Обратите внимание, что я не хочу использовать.htaccess, так как считаю, что это устарело.

0 ответов

Другие вопросы по тегам