Web Hosting Talk







View Full Version : Prevent directory listing


raylin
05-19-2001, 09:49 AM
How to prevent directory listing like:
http://www.webhostingtalk.com/images/

Mirco
05-19-2001, 10:41 AM
upload a blank index file :)
(or do it with the apache directive)

raylin
05-19-2001, 11:29 AM
I knew a blank index.html can do that, but don't know how to do this with the apache directive.

jtan15
05-19-2001, 11:50 AM
In the directory that you do not want the directory list to be shown, create a file named ".htaccess" with the following line in it:

Options -Indexes

This sets the option "Indexes" to off, which means it will no longer show a directory index.

Hope this helps! :)

raylin
05-19-2001, 12:02 PM
Thanks,

But is it possible to do this in a 'server-wide' way ?

projo
05-19-2001, 12:02 PM
Or for more fun. Browse to a page where Apache (or another server) shows the directory
listing. View the source and copy the code. Use this code to create an index.html
page in the directory of your choice. Now viewers will think they are seeing your
directory listing but are in fact seeing the mask. You can even change the links,
such as "parent directory" to give a "sorry you can't do this", or other responses.
Reminds me of the movie "Thirteenth Floor."

These are the kinds of things to do while between service tickets, i.e. create a virual
reality. Hi.
Gary

jtan15
05-19-2001, 12:22 PM
Originally posted by raylin
Thanks,

But is it possible to do this in a 'server-wide' way ?

Yes. Insert this code into your httpd.conf:

<Directory "/home/*/public_html")
Options -Indexes
<Directory)

Change the ")" to ">". This way you can not view any directory listings in any directory in any public_html. :)

raylin
05-19-2001, 12:31 PM
Many thanks, :)