Web Directory Listings


How to display the contents of a web directory.

By default the webserver will look for an index.html file in a web directory and serve that. If one doesn't exist a message will be displayed about how you do not have permission to access this directory on the server. What this really means is that the web server is not allowed to simply print a list of all the files in that directory to the screen.

It is useful sometimes though to simply use a web directory as a file repository for easy web access.
If you want to allow the Apache webserver to display the contents of the web directory you just need to tell the webserver that it is allowed to display the contents of this directory.

This is done by placing a .htaccess file in the directory with the follwoing line in it.

Options +Indexes

This tells the server to allow the automatic creation of a Directory Index (list of all the files in the directory).

For convenience a sample .htaccess file is attached below. YOU MUST RENAME THE FILE .htaccess and place it in the directory to enable listing the directory contents.