LinuxWorld

Showing long file names in Apache directory listings

We use the directory index listing feature to display the directory of our document archive on an Apache Web server. Long file names are getting chopped off by Apache in the generated Web pages. Can we configure the server to show the entire file names in directory index listing pages?

Yes - Apache versions 1.3.2 and later can use configuration directives provided by the mod_autoindex module to customize the appearance of automatically generated directory index listings. To do this, use the NameWidth option available as part of the IndexOptions directive.

This directive can be used in the main server configuration file, a virtual host or directory configuration section, or in a directory-level htaccess file. Place a line in your configuration that looks like "IndexOptions NameWidth=*". The asterisk is a wild card that tells Apache to give as much space to the file name column as needed to show the longest file name in the list.

You can set a specific width by replacing the asterisk with the number of characters you want to use for the column. Other options include FancyIndexing to show file and folder icons, and FoldersFirst to tell Apache to list folders above file names in directory listings.

React: Give us your thoughts on the issues here.
Use this form to start a public discussion with other Linux World users on this article.
Log In | Register for an account (Why you should)

Note: Register to have your user name appear; otherwise your comment will show up as "Anonymous."

*Anonymous comments will only appear once they are approved by the moderator.

Newsletter sign-up

Sign up for one of Network World's newsletters compliments of Linux World

Linux & Open Source News Alert
Web Applications Alert
Video & Podcast Alert
Security: Threat  Alert
Virtualization Alert

Email Address: