2

I've a folder structure like:

        home
         |
snippets---other----bla
   |        |        |
a--b--c   d--e--f  g--h--i
|  |  |   |  |  |  |  |  |
filesfilesfilesfilesfilesfiles

I've default files (index.html) in most folders, but for the folders without default files, I used "Options -Indexes" in the home .htaccess to generate a 403 error. In the snippets folder, I use custom directory listing.

<IfModule mod_autoindex.c>
    Options +Indexes
    IndexOptions IgnoreCase VersionSort SuppressHTMLPreamble
    ReadmeName ../index_end.html
    HeaderName ../index_begin.html
</IfModule>

Inside the snippets folder Options +Indexes rules. However, I want to prevent directory listing in folder a,b,c. Is there a solution which doesn't needs an htaccess file for every folder? I only have access to htaccess

1 Answer 1

2

Assuming you have access to the httpd.conf file or your virtual host configuration, You can add Directory sections with Wildcards, or DirectoryMatch sections to accomplish this in your httpd.conf file. You're probably looking for something akin to:

<Directory /home/snippets/*>
    Options -Indexes
</Directory>

Make sure you read up on how various configuration settings are merged.

2
  • I only have access to .htaccess ):
    – bopjesvla
    Commented Jun 5, 2011 at 17:06
  • With only .htaccess available, sadly I don't know of a better way. You might be able to use symlinks or hard-links so that you only have to write it once and have the same .htaccess in each folder, but that working is dependant on the server configuration.
    – Charlie
    Commented Jun 18, 2011 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.