Nicer Indexes in Apache

by Rob Flickenger

Have you ever noticed how Apache annoyingly chops off filenames in directory listings?

You can always make it show the full name by changing IndexOptions line in httpd.conf:

IndexOptions FancyIndexing NameWidth=*

While you're at it, you might find this tweak useful. Many people (myself included) don't want to allow directory indexing on /home/*/public_html by default, so users don't "accidentally" publish something just by copying it to their public_html directory. So, the typical user entry in httpd.conf looks something like this:

<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews FollowSymLinks Includes

...with some LIMIT lines thrown in for good measure. The problem is that sometimes you WANT to turn on indexing (say, for a local file repository.) You could hack the httpd.conf to allow this in each case... However, if you add a couple of entries to the AllowOverride line:

<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Options Indexes
Options MultiViews Includes

...then you can turn on and off directory listings at will with a per-directory .htaccess file. Create an .htaccess in each directory that you want to enable indexing with this line in it:

Options Indexes

And magically, these directories are now indexed. There's the added bonus that you can now use AddDescription lines to this .htaccess file, like so:

Options Indexes
AddDescription "Lucent Wavelan drivers" wavelan
AddDescription "Nessus security scanner" nessus
AddDescription "OpenSSH and Libraries" ssh
AddDescription "Some photos" pix

These descriptions will now show up under the "Description" column in your browser. And the big bonus: your users can do this without ever bothering you for sysadmin intervention.