- 1 Vapor IO Brings OpenDCRE to General Availability
- 2 VMware Takes the Wraps Off vRealize Automation and vRealize Business
- 3 Microsoft Previews Hyper-V Containers for Windows Server 2016
- 4 Mirantis Led FUEL Project Gets Installed Under OpenStack Big Tent
- 5 Red Hat Enterprise Linux 7.2 Adds Security, DR Features
Apache Guide: Generating Fancy Directory Listings with mod_autoindex Page 2
IndexOptions directive provides a list of options to set
various features of the index listing. These options don't
warrant their own directive, and so are lumped together here.
The syntax of the
IndexOptions directive is:
IndexOptions +option1 -option2 ...
Options marked with + will be included in the set of options, and those marked with - will be ommitted. Note that if you forget the + or - in that list, the last item on the list is all that you get. That is,
IndexOptions SuppressDescription ScanHTMLTitles
is exactly the same directive as
And, furthermore, it overrides all previous
that are already active. Don't forget the + and -!
I'm not going to go over all of the available options - see the docs - but here are a few that I like.
Those of you that are used to a graphical representation of your directories -- something like the Windows file explorer, for example -- are used to seeing the directories at the top of the listing, and the files below that. The default Apache view is to have the directories listed in the same alphabetic ordering as the files.
To override this behavior, use the
IndexOptions +FancyIndexing +FoldersFirst
Note that the
FancyIndexingoption is necessary for several of the options to work, including this one.
ScanHTMLTitlesoption, you can get a description of each HTML file in a listing by looking in the <TITLE> tag of each file. If you have written good HTML, this will give a very good idea of what each file is, before the user downloads. Note that in order to do this, Apache will need to open each file and parse it looking for a title tag. This can take a long time, and use up a lot of system resources.
An exceptionally useful feature of
mod_autoindexis the ability to provide descriptions for your files, and have these descriptions appear in the directory listing. This is accomplished with the
AddDescriptiondirective. As with several of these directive, you can specify exact file names, or you can give wild-cards to indicate a group of files.AddDescription "My dog" /images/fido.jpg AddDescription "PNG images" *.png
If you are in the habit of using really long file descriptions, or if you are using the
ScanHTMLTitlesoption above, you might find that the space allocated to you for displaying a description is insufficient. You can correct oft this with the
DescriptionWidthoption. This is an option for the
IndexOptionsdirective. You can specify a particular width, or you can specify ''*'', indicating that the field should be wide enough to accomodate the largest description you have.IndexOptions +DescriptionWidth=42
OK, one more. It may be desirable to display some informative text at the top of a directory list. This may be information about the files in the directory, or it might be administrative information about the server. Or whatever. The
ReadmeNamedirectives allow you to indicate a file that will be put at the top or bottom (respectively) of the directory listing. The argument for this directive is a filename stub. That means that if you have: