Matteo Mattei

Hello, my name is Matteo Mattei and this is my personal website. I am computer engineer with a long experience in Linux system administration and web software development.

linkedin rss twitter google+ github facebook

Hide file and directory in Apache disabling browsing

If you want to disable file and directory browsing on your Apache web server in order to prohibit that every users can view the content of a directory (if noindex.php/index.html is present) you need to modify the Apache configuration a little or add a new statement in .htaccess file.

I will show you how to do in both cases:

  1. Apache configuration: httpd.conf/virtual-hosts
    Edit your virtualhost adding these rows:
<Directory "/home/httpd/html/mydomain/files">
    Options -Indexes
</Directory>
  1. .htaccess
    Add in the .htaccess file this row:
Options -Indexes

In the first case you need to restart apache server.

comments powered by Disqus