Curt
Curt

Reputation: 1181

Exclude directory from mod_autoindex.c Options -Indexes

I have the following in my .htaccess:

# "-Indexes" will have Apache block users from browsing folders without a
# default document Usually you should leave this activated, because you
# shouldn't allow everybody to surf through every folder on your server (which
# includes rather private places like CMS system folders).
<IfModule mod_autoindex.c>
  Options -Indexes
</IfModule>

However, I have a directory that does not have an index file (and I prefer to keep it this way), which I need to enable access. How do I exclude this directory from the above code?

Upvotes: 0

Views: 1236

Answers (2)

Curt
Curt

Reputation: 1181

Despite the following comment (I got this code from someone else):

# "-Indexes" will have Apache block users from browsing folders without a
# default document

...this code does not block users from accessing files in a directory that does not have an index file. Therefore, I do not need to exclude my directory from the above code.

As an example, example.com/testdir does not have an index file. But, I'm able to access example.com/testdir/testfile.txt

Upvotes: 0

sa289
sa289

Reputation: 700

Create an .htaccess file in that directory, and in it put the following

<IfModule mod_autoindex.c>
  Options +Indexes
</IfModule>

Upvotes: 1

Related Questions