home | blog | archives | bsod | wtf | news | contact | about      
    Using Unix | Apache - Modifying directory listings | Posted 23.05.2006 by AndyM

Apache - Modifying directory listings


The directory listing view in Apache is what you see if there is no index.* file in the directory which is being viewed.

In the absence of an index.htm (or index.html, index.php, etc.) Apache may reveal a listing of all files and directories in the directory being viewed.

The may refers to the possibility that this feature might be turned off as some consider it a security risk.

All web directories generally contain an index file and its presence prevents the ability to view a directory listing - the viewer is simply shown the index file itself, which links to other files in the usual way. However if directory listing view is enabled in the Apache server's configuration and there is no index file, then the reader is presented with a view similar to this:

Apache directory listing

This view can be useful if you use the directory as a repository for files and can't be bothered to create an index file, which hyperlinks to each file listed. An alternative is to leave out the index file and enable directory view in httpd.conf. Under these circumstances Apache makes the list for you and users can download the files by clicking on the list. Nice.

One limitation is that longer file names get truncated in the default directory list view. Hard to read. To widen the view, edit httpd.conf..

Modifying httpd.conf

This file is the main configuration file for Apache and it is wise to make a backup before modifying it, just in case..

cp  /usr/local/apache/conf/httpd.conf   /usr/local/apache/conf/httpd.conf.bak

Note that the location of httpd.conf can vary depending on the system and version being used. Find the following section and add the line in bold below..

vi  /usr/local/apache/conf/httpd.conf

 <Directory />
 IndexOptions NameWidth=*
 </Directory>


To make the changes happen, restart the Apache Service. Again the method may vary..

/usr/local/apache/bin/apachectl   restart

The new directory listing view should widen to accomodate the longest file name..

Apache directory listing

- A.





Bookmark and Share










Copyright 2010-11 © TheSystemMaster.com. All Rights Reserved.   |   Web design by PaddedCell   |   Hosting by VirtualHost