Search blog

Friday, April 3, 2015

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

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.

Source: https://support.tigertech.net/directory-index

No comments:

Post a Comment

Thank you for your Feedback!
www.evagabond.me

Top 5 Posts (Weekly)