What is the htaccess Options -Indexes for?
Asked Answered
R

3

45

I looked at the explanation in the apache.org site but it didn’t explained in a way I can understand. I found some info here .htaccess File Options -Indexes on Subdirectories but it doesn’t explain it either.

Rawden answered 5/4, 2013 at 15:30 Comment(0)
T
61

The Indexes option sets whether you can "browse" the directory or not. If indexes is set to plus, and the directory has no index.html or index.php (of whatever) file, it will show the contents of the directory just like your filemanager would do. So if there are ten images in there, it simply shows them as a list with links to the actual image. You can click them and open them.

Most of the time this is not what you want. You don't want others to see what is inside that folder. So then you turn it off with -Indexes.

Here you can see an example of an open dir, as they are called: http://www.ecoutetpartage.fr/images/

Tanguy answered 5/4, 2013 at 15:43 Comment(0)
E
11

-Indexes supresses the possibilty of directly listing files in a directory where no DirectoryIndex is set.

Assume a httpd DirectoryIndex set to: DirectoryIndex index.html index.php.

If you have no file in your RootDirectory according to the DirectoryIndex httpd (in this example index.html and index.php) variable, your directory contents will be listed when +Indexes ist set. Your directory contents will never be displayed when -Indexes is set.

Emylee answered 5/4, 2013 at 15:44 Comment(0)
H
0

If there is no index file like index.html or index.php, then visitor will be able to see this specific folder files and inner folder. Definatly we don't want to go. That's why we create .htaccess file in the root of the folder and put the code Options -Indexes.

This will prevent visitors to access the folder and inner assets.

Hypabyssal answered 10/7 at 4:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.