How to disable directory indexing from apache2 whe

2019-04-05 03:56发布

问题:

I need to disable that indexing when I enter on my root directory on a apache2 server, any tips?

回答1:

If it's only one directory that you want to protect from viewing contents, you can also just add an index.html or index.php that will show whenever someone browses to that directory.



回答2:

Edit your apache2 configuration file which normally is on the dir: "/etc/apache2/httpd.conf".

Add the following or edit if your already have some configurations for the default web server dir (/var/www):

 <Directory /var/www>
   Options -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
 </Directory>

This will disable the indexing to all the public directories.



回答3:

Usually done like this:

Options -Indexes

The minus means "no"...



回答4:

Make sure that you also add -Indexes to the config files in your sites-enabled (or sites-available as it was in my case) directory, they're usually inside the "/etc/apache2/" directory.