Previous suggestions about putting a blank index.html in each directory that you do *NOT* want a directory listing to be generated in will work.

But, are you sure your web host's webserver config allows access to those directories other than cgi-bin?

I just looked in my apache httpd.conf file, and if I interpret this correctly it explains that the default setting of

<Directory /> Options FollowSymLinks AllowOverride None </Directory>

for the root '/' directory, restricts access to that directory and all directories below, unless overridden by definitions for specific subdirectories(under '/'). So since this 'Directory /' definition(this is the default on my machine) doesn't specify 'Indexes', then no directory index listings will be generated for any directory unless expressly enabled by an 'Option Indexes' in a 'Directory' definition entered into the httpd.conf file.

So looks to me like you may(?) already be protected by your web host's webserver config. But if not, then either

1. put a blank index.html in each directory you want to protect(against directory listing), OR 2. assuming the webserver config is configured for it, you can also put a .htaccess file in each directory you want to protect.
HTH.

In reply to Re: preventing directory browsing by hmerrill
in thread preventing directory browsing by db2admin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.