Conner Burnett
Conner Burnett

Reputation: 512

allow access to certain directories in htaccess

In htaccess I am blocking directory browsing by using the following code.

# directory browsing
Options All -Indexes

However, I want people to have access to a certain folder, let's say the folder is called pictures, so the folder is at mysite.com/pictures.

How do I give access to that folder/directory, but keep the rest blocked?

Upvotes: 2

Views: 6120

Answers (1)

Philip
Philip

Reputation: 1542

Put a .htaccess file into your pictures folder, with this line:

Options Indexes

(or "+Indexes", which is the same.) That should take care of it because child .htaccess files override parents.

From your question it's not clear that you understand the limitations of "Options Indexes". This does not "block" access to a directory; it merely turns off an auto-generated directory listing. Knowing a filename, anyone can still access the resource whether Indexes are enabled or not.

Upvotes: 5

Related Questions