Disable directory listing/browsing – Apache

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.

Often, you don’t want your website users to browse the whole content of a public folder.
They will still be able to download files contained in it (like javascript or css files) but not to list all of them for no reason.

This can be achieved in different ways. For example modifying the apache configuration file directly or trough the .htaccess.
Here today we quickly explain the first method.

So, open your apache configuration file for the website you want to amend. Where it is depend on your linux distribution.
In Ubuntu Lucid it’s in: “/etc/apache/sites-enabled/website_name”.
Open the file as administrator with your favorite editor and look for something like:


    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

and remove the option “Indexes” so that the config file will look like:


    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all

Now you just need to restart your apache server to reload your new configuration file.

In Ubuntu it’s done with:

sudo /etc/init.d/apache2 restart

Enjoy!

One thought on “Disable directory listing/browsing – Apache”

Leave a Reply

Your email address will not be published. Required fields are marked *