How to enable/disable directory listing with .htaccess

On many web servers, directory listing is disabled by default. The idea is that if you don’t have an index file in a directory a 403 HTTP Forbidden Access error will be return. The client will not be able to see the files in the directory. Anyway, some users want to be able to list the files in a specific directory.

To enable directory listing:

  1. Navigate(via a file manager or FTP/SSH client) to the directory you want to enable directory listing for
  2. Create/edit the .htaccess file
  3. Add the following line on the top of the file:
Options +Indexes

directory listing
Enable/disable directory listing

To disable directory listing:

  1. Navigate(via a file manager or FTP/SSH client) to the directory you want to disable directory listing for
  2. Create/edit the .htaccess file
  3. Add the following line on the top of the file:
Options -Indexes

Resources:
Apache Module mod_autoindex

Leave a Reply