Denying Directory Listing With htaccess

Just type:

Options -Indexes

That’s it!

8 Comments

  1. Posted June 14, 2008 at 11:04 am | Permalink

    I wish I had the same way of expressing myself in code the way you do. LOL. :)

  2. Posted June 15, 2008 at 11:33 am | Permalink

    Where did my comment go ? Am i err delisted? What’s up? It is as bad as the WP forum ?:) LOL.

    PS: You need to be a Japanese caligraphist to understand your captcha graphics. :)

  3. Posted June 15, 2008 at 1:13 pm | Permalink

    No, you weren’t marked as spam, I just didn’t turn my computer on yesterday but until today and found your comments in the queue. Sorry for posting them late.

    :D

  4. Posted July 17, 2008 at 3:47 am | Permalink

    I have two questions:

    1. On a shared hosting if the host does not give you Override all, should this “Options -Indexes” work on my .htaccess file?

    2. What should I do if I want to deny directory listng on an entire website but allow just one directory?

    Thanks in advance :)

  5. Posted July 17, 2008 at 11:25 am | Permalink

    WebTenet,

    1) I think you’re talking about the AllowOverride directive, correct? If the hosting provider has set it to None, then your .htaccess file will completely be ignored.

    2) In the directory, where you want to allow directory listing, you should place an .htaccess file with the following: Options +Indexes

    HTH

  6. Posted August 8, 2008 at 10:53 pm | Permalink

    Sometimes the following string will also work:

    IndexIgnore *

  7. Posted November 12, 2008 at 4:51 am | Permalink

    Hi, do you mean that people can not see in the root directory?

  8. Posted November 12, 2008 at 5:04 pm | Permalink

    Digatex,

    If I understood your question well, then the answer is that the root (or any other) directory listing shouldn’t be allowed. Obviously, if the root (or any other) directory lacks of an “index” file, the person trying to access such directory would see a 403 message:

    Forbidden

    You don’t have permission to access /[directory_name]/ on this server.

    HTH