Apache – Turn On/Off Directory Listing

If a client requests a URL that designates a directory and the directory does not contain a filename that matches the DirectoryIndex directive, then mod_autoindex can be configured to present a listing of the directory contents.

Turn on directory listing

To turn on automatic directory indexing, find the Options directive that applies to the directory and add the Indexes keyword.

For example:

<Directory /path/to/directory>
    Options +Indexes
</Directory>

To turn off automatic directory indexing, remove the Indexes keyword from the appropriate Options line. To turn off directory listing for a particular subdirectory, you can use Options -Indexes.

Turn off directory listing

For example:

<Directory /path/to/directory>
    Options -Indexes
</Directory>