.htaccess to prevent navigation

0

I have a Debian server and the directory for the projects in apache is the traditional / var / www / html, I'm trying to block the browsing of directories and sub-directories by browser with .htaccess but I'm not hitting.

The .htaccess code is in the html folder with 644 user permission www-data:

<Directory /var/www/html>
    AllowOverride All
    Options -Indexes
</Directory>
    
asked by anonymous 22.06.2017 / 19:57

1 answer

1

Try this:

<Location /my_folder/>
    Order Deny,Allow
    Deny from all
</Location>

Or this (depends on the server version)

<directory /my_folder/>
    Order Deny,Allow
    Deny from all
</Location>

Apache configuration

Edit the apache configuration file, usually at /etc/apache2.conf browse to the list of available directories, a block like that (copied from a debian google cloud virtual machine):

<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>

Change the AllowOverride directive to:

 AllowOverride All
    
22.06.2017 / 21:24