How do I enable directory listings for a folder on my website?

If a directory doesn't contain an index file (a file named "index.html", "index.htm", "index.php", etc.), Web servers will normally show an error message if someone uses a Web browser to visit the URL address of that directory.

This provides security for your files: it prevents strangers from viewing the names of all files in a directory and snooping through them, possibly finding files that are intended to be private.

However, if you actually want your site visitors to be able to see all the files in a directory, you can do that by placing a file named .htaccess in the directory. The file should contain this line of text:

Options +Indexes

(This command is explained in the Apache Web server documentation.)

After you do that (and also remove any index file such as "index.html" from the directory), anyone visiting the address of the directory will be able to view a list of all files in it and click on the individual files to open them.

Advanced directory listing customization

You can customize the directory listings by setting certain options for the mod_autoindex module.

The following lines display a file's full name, no matter how long it is:

Options +Indexes
IndexOptions FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=*

Or you can set a character length limit, like this:

Options +Indexes
IndexOptions FancyIndexing FoldersFirst NameWidth=30 DescriptionWidth=30

You can suppress the display of file icons by adding the SuppressIcon option:

Options +Indexes
IndexOptions FancyIndexing FoldersFirst SuppressIcon

See the Apache Web server mod_autoindex documentation for full details about IndexOptions.

What if I don’t want other people to see the directory listings?

We have a separate page explaining a (more complicated) way to create private directory listings.

Having trouble?

If you aren't comfortable working with .htaccess files, we can do this for you. Just contact us and let us know the URL for which you want to enable directory listings.