Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I prevent external users from somehow getting a list of files that are on my machine?

For instance, My website is in folder /htdocs/ and I have some other random documents in there too.

How do I make sure that the user can only see the site and can never get an overview of what files I have on that harddrive?

share|improve this question
Seems like a ServerFault question to me – David Z Jun 7 '09 at 0:42
up vote 6 down vote accepted

With Apache, you can create a .htaccess file like this:

 Options -Indexes

For more details, check out How to Prevent a Directory Listing of Your Website with .htaccess

share|improve this answer
+1 good answer :) – David Pashley Jun 7 '09 at 7:25

assuming apache look at this page for some good security tips

in specific add to httpd.conf

<Directory />
     Order Deny,Allow
     Deny from all

<Directory /htdocs>
     Order Deny,Allow
     Allow from all
share|improve this answer
Directory entries very much like these are default, but it's a good idea to check to make sure. +1 – Matt Simmons Jun 7 '09 at 1:37

Also, you could restrict the apache user via SELinux policy. If you are on a system with SELinux that is...

Look at his article on secure containers (lightweight virtual machines). Perhaps for the more paranoid or those who have problems of scale.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.