Click here

Tip of the Trade: Directory Indexes in Apache

By Carla Schroder (Send Email)
July 25, 2006

This little hack is so easy, that we have an almost have a missionary zeal to spread it to Apache Webmasters everywhere. In addition to its simplicity, it's a great convenience to visitors. How many download sites have you visited that display file indexes like this?

Index of /pub/asterisk
Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory                             -   
[   ] ChangeLog-1.2.9.1       06-Jun-2006 11:37   93K  
[   ] ChangeLog-1.2.9.1-ne..> 06-Jun-2006 11:37   93K  
[   ] ChangeLog-addons-1.2.3  01-Jun-2006 17:50  3.4K  
[   ] INSTALL.README.X100P    04-Dec-2005 18:21  2.8K  
[   ] INSTALLX100P.ps         04-Dec-2005 18:21  309K  
[DIR] appnotes/               04-Dec-2005 18:21    -   
[   ] asterisk-1.2-current..> 06-Jun-2006 11:37   10M  
[   ] asterisk-1.2-netsec-..> 06-Jun-2006 11:37   10M  
[   ] asterisk-1.2.9.1-net..> 06-Jun-2006 11:37  1.5K  
[TXT] asterisk-1.2.9.1-net..> 06-Jun-2006 11:37  378   
[   ] asterisk-1.2.9.1-net..> 06-Jun-2006 11:37   75   
Now, how in the heck are you supposed to deal with this? Really, this is so last-millennium. True, most Web browsers display the full filename at the bottom as the mouse hovers over the filename. But is this not the 21st century? Must we remain trapped in a truncated filename mentality?

To find your way to the present, expose the entire filenames by adding these lines to httpd.conf:

IndexOptions FancyIndexing VersionSort
IndexOptions FancyIndexing VersionSort NameWidth=40
That sets the maximum to 40 characters, which is long enough for most sites. Naturally, this can be tweaked as desired, so you get a nice readable display like so:


Index of /linux/fedora/linux/core/5/i386/os/Fedora/RPMS
Icon  Name                                                             Last modified      Size  Description
[DIR] Parent Directory                                                                      -   
[   ] ElectricFence-2.2.2-20.2.i386.rpm                                06-Mar-2006 14:54   31K  
[   ] GConf-1.0.9-20.i386.rpm                                          06-Mar-2006 16:38  562K  
[   ] GFS-kernel-2.6.15.1-5.FC5.17.i686.rpm                            14-Mar-2006 18:48  182K  
[   ] GFS-kernel-smp-2.6.15.1-5.FC5.17.i686.rpm                        14-Mar-2006 18:48  184K  
[   ] GFS-kernel-xen0-2.6.15.1-5.FC5.17.i686.rpm                       14-Mar-2006 18:48  188K  
Now, isn't that ever so much nicer! It really is that simple; check your Apache documentation if you don't believe us.

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.


 

 


Networking Solutions