bopjesvla
bopjesvla

Reputation: 763

Directory listing for one folder htaccess

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

Upvotes: 2

Views: 4858

Answers (1)

Charlie
Charlie

Reputation: 7349

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.

Upvotes: 2

Related Questions