How to disable directory listing / directory browser for a Virtualhost on Linux Apache

Wednesday, 15th September 2010

I’m creating two new subdomains for a domain.com and I’m building up the VirtualHost configuration files for them.
After I’ve bringed the Virtualhosts online I’ve noticed that I forgot to Disable the Directory listing for that domains e.g. Directory Browsing was enabled for each of the two new subdomains I’ve created.

In order to deal with the situation all I had to do was change just one Apache directive in my Virtualhost configuration file :

Here is how my Virtualhost configuration conf file looked like before the change:

<VirtualHost *>
ServerAdmin admin@mydomain.com.com
ServerName subdomain.mydomain.com

DirectoryIndex index.php index.html index.htm
DocumentRoot /home/mydomaincom/subdomain/
<Directory /home/mydomaincom/subdomain/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</Directory>

The configuration directive I had to change was Options Indexes , I had to substitute it with Options -Indexes

So eventually after the change my Virtualhost with disabled Directory listing for the Apache looked like:

<VirtualHost *>
ServerAdmin admin@mydomain.com.com
ServerName subdomain.mydomain.com

DirectoryIndex index.php index.html index.htm
DocumentRoot /home/mydomaincom/subdomain/
<Directory /home/mydomaincom/subdomain/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</Directory>

I know this is pretty basic stuff but however I do tend to forgot how to disable the directory listing each and every time I decided to blog it here just to be easier for me to repeat the Directory Indexing prohibition for the future.
I’ll be glad if that’s helpful to somebody out there.

Share this on:

Download PDFDownload PDF

Tags:

3 Responses to “How to disable directory listing / directory browser for a Virtualhost on Linux Apache”

  1. freezone says:
    Firefox 8.0.1 Firefox 8.0.1 Windows Server 2003 Windows Server 2003
    Mozilla/5.0 (Windows NT 5.2; rv:8.0.1) Gecko/20100101 Firefox/8.0.1

    Absolutely what I was googling for …
    Many thanks.

    View CommentView Comment
  2. only2b says:
    Google Chrome 23.0.1271.64 Google Chrome 23.0.1271.64 Mac OS X 10.8.2 Mac OS X 10.8.2
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11

    Thanx a lot ! Thats what i was looking for…

    View CommentView Comment

Leave a Reply

CommentLuv badge