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?

  • Seems like a ServerFault question to me
    – David Z
    Jun 7 '09 at 0:42

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


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
  • Directory entries very much like these are default, but it's a good idea to check to make sure. +1 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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