If when accessing any folder which does not contain an index file ( ex: http://yourtestdomain.com/folder/ ) a directory listing will be shown displaying a list of the files in that folder. Simply adding a zero size (0 byte) text file named “index.html” or “index.php” will prevent this directory list from being displayed.
Another way and the best method is to disable directory listing is by adding the following line to the .htaccess file in your home folder ( public_html ) of your web hosting account :
Disabling directory listings using .htaccess.
That’s it, with this line in place, folders which do not contain index files will no longer show the default directory list. Doing it this way is all sub-directories of that directory will also get their directory listings turned off. You could then turn on indexes for one of those sub-directories just by making another .htaccess file in that directory with:
If you want the directory contents to be listed, but only if they were HTML pages and not images. Adding the following line to the .htaccess file.
IndexIgnore *.bmp *.jpg *.gif *.png
This would return a list of all files not ending in bmp, jpg, gif or png, but would still list another files like: .txt, .html .css .pdf, etc .