Web Hosting Talk







View Full Version : .htaccess and directory listing...


the-omega
06-18-2001, 06:39 PM
Does anyone know how to use .htaccess to not allow directory listings?.....NOT password protecting them...just not allowing directory listings....

Ericd
06-18-2001, 07:06 PM
Put this in your htaccess, and you will get a Forbidden ( 403 ) page.

Options Includes FollowSymLinks

Cheers!

the-omega
06-18-2001, 07:08 PM
I thought it was supposed to display a 404 Not found error?

Ericd
06-18-2001, 07:10 PM
No, 404 are for Page Not Found, however, when you don't allow listing, the directory is there, it's just forbidded for http access :)

Annette
06-18-2001, 07:10 PM
Does your host have directory listing available serverwide? If so, you can negate that for your site by using

Options -Indexes

the-omega
06-18-2001, 07:14 PM
Annett....will that not allow dir listings for my WHOLE site?

Thanks HostAB and Annett

Jedito
06-18-2001, 07:39 PM
Why don't you try a blank index.html? :)

Annette
06-18-2001, 07:55 PM
If you place that in the root of your site, the directive will be applied for all folders underneath it as well. If you only want to restrict listings of certain directories, put your .htaccess in those directories instead.

Those that suggest a blank index.html have a valid suggestion, but it's easier to take care of directory listings with one file in one place versus numerous (blank) files all over the place (not to mention making sure that every new directory has that blank file in it).

Jedito
06-18-2001, 09:12 PM
Those that suggest a blank index.html have a valid suggestion, but it's easier to take care of directory listings with one file in one place versus numerous (blank) files all over the place (not to mention making sure that every new directory has that blank file in it).

true true :D

the-omega
06-18-2001, 10:15 PM
Thanx for your help :)