Disable directory listing on apache; but access to individual files should be allowed

Deepak Singhal picture Deepak Singhal · Jun 21, 2012 · Viewed 42k times · Source

I do not want to use .htaccess. How should I change my Directory attributes?

<VirtualHost *:80>
   ServerName abc.com
   DocumentRoot /usr/share/uploads
   <Directory " /usr/share/uploads">
      Order allow,deny
      Allow from all
   </Directory>
</VirtualHost>

Answer

Natxet picture Natxet · Mar 6, 2013

If you are using Debian/Ubuntu, just go to terminal and type

sudo a2dismod autoindex
sudo service apache2 restart

If you are using Centos/Fedora, just do:

mv /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/autoindex.bkp
/etc/init.d/httpd restart

And similarly in other OS or distros...

This should disable the apache module that makes those fancy (normally useless and a security problem) directory listings. Also, as a bonus, you earn a bit of performance :-)