How to disable directory listing / directory
browser for a Virtualhost on Linux Apache
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.