colourcolourcolourcolourcolourcolourcolour
Forgot my colour selection

Using mod_autoindex For Informative Indexing

The Apache module autoindex is installed on most shared hosting around today, and is either enabled by default or can be enabled by setting FancyIndexing on in your .htaccess file in the root of the folder.

I was looking for what the “Description” column was for while I was looking around one of my folders using the Apache directory listing, and I came across the documentation for Apache autoindex. It turns out there are some cool options you can use to customise the look of your listings. The AddDescription directive is an awesome setting that allows files and folders in a directory to have a description, using htaccess.

An example of what can be achieved using the setting is over on my download subdomain, http://download.alanedwardes.com/. I’ve given each of the directories descriptions and made the width of the “name” and “description” colums fluid, so nothing gets cut off. All this can be achieved easily using only the “AddDescription” and “IndexOptions” directives in a .htaccess file.

In the case of my download folder, this is the code I’ve used:


AddDescription "My first WordPress theme called Crisp." crisp
AddDescription "A dark style for Shaun Inman's Mint." dark-pepper-mint-style
AddDescription "An app to hide the remove hardware icon." hide-remove-hardware-icon
AddDescription "My second WordPress theme. Uses PHPGD for headers." lime-juice
AddDescription "A PHP script to pull random images from Flickr." php-flickrstream
AddDescription "An example of PHP intergrated with Flash." php-in-flash
AddDescription "A pretty random post redirect script for WordPress." pretty-random-redirect
AddDescription "Pretty search script for WordPress." pretty-search
AddDescription "Comparison of video quality on video sharing sites." screen-test
AddDescription "Search forms and how to create them in flash." search-form-in-flash
AddDescription "A demonstration of Windows Movie Maker HD in Vista." windows-movie-maker-hd

IndexOptions DescriptionWidth=*
IndexOptions NameWidth=*

The format of AddDescription is to print the description you want in quotes, then to put the folder or filename after it.

AddDescription "Testing the folder descriptions" foldername

The IndexOptions DescriptionWidth=* and IndexOptions NameWidth=* make it so the columns for name and description are fluid, meaning that they will not get cut off if the content is longer than a few words (the default cut of length).

Using these options you can avoid using bloated PHP fancy listings that overcomplicate a simple folder listing, not to mention make it much faster that using such a method.

Posted on August 24th, 2008. Filed under Awesome, Code, Natural, and tagged with , .

Leave a Comment

Make yourself heard

Montly Post Archives

Posts from previous months