Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I haven't uploaded index.html or index.php to my root directory. How can I prevent people from looking at a listing of files in parent directory?

http://oi56.tinypic.com/sc739e.jpg

Also, is it possible for people to obtain a list of all the files in the root directory once I upload index.html?

I'm currently using .htaccess and htusers to prompt someone to enter a username and password when they try to access any file in the root directory.

This may sound like a weird request but would it be possible to have them come to the site (without an index.html) and just have them not see the files? All it would say on the page would be the following:

Index of/

Apache Server at mysite.com Port 80

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Use Options -Indexes to turn off auto-generation of indexes.

share|improve this answer

Add this to your .htaccess:

Options -Indexes

it will show an "Forbidden 403" Error when a user tries to access the page.
Also after you have uploaded an proper index.html the users won't be able to get the listing.
It is still good practice to keep the -Indexes Option in it if you don't want ever to show the list, in case for example of a misconfiguration or you moved the index.html away by accident.

share|improve this answer

In addition to AlexD's answer, you can try putting in .htaccess:

IndexIgnore *.csv

for specific file extensions.

More help is available at http://httpd.apache.org/docs/current/howto/htaccess.html

share|improve this answer

Your Answer

 
discard

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.