IndexOptions
IndexOptions option [option] ... (Apache 1.3.2 and earlier) IndexOptions [+|-]option [[+|-]option] ... (Apache 1.3.3 and later) Server config, virtual host, directory, .htaccess
This directive is somewhat complicated, and its syntax varies drastically depending on your version of Apache.
+/-
syntax and merging of multiple
IndexOptions
directives is only available with
Apache 1.3.3 and later; the FoldersFirst
and
DescriptionWidth
options are only available with
Apache 1.3.10 and later; the TrackModified
option
is only available with Apache 1.3.15 and later.
The IndexOptions
directive specifies the behavior
of the directory indexing. option
can be one of
the following:
The DescriptionWidth
keyword allows you to specify
the width of the description column in characters. If the keyword
value is *
, then the column is automatically sized
to the length of the longest filename in the display. See
AddDescription
for dangers inherent in truncating
descriptions.
This turns on fancy indexing, which gives users more control over how the information is sorted.
Note that in versions of Apache prior to 1.3.2, the
FancyIndexing
and IndexOptions
directives will override each other. You should use
IndexOptions
FancyIndexing
in
preference to the standalone FancyIndexing
directive. As of Apache 1.3.2, a standalone
FancyIndexing
directive is combined with any
IndexOptions
directive already specified for the
current scope.
If this option is enabled, subdirectories in a
FancyIndexed
listing will always appear first,
followed by normal files in the directory. The listing is basically
broken into two components, the files and the subdirectories, and
each is sorted separately and then displayed with the subdirectories
first. For instance, if the sort order is descending by name, and
FoldersFirst
is enabled, subdirectory
Zed will be listed before subdirectory
Beta, which will be listed before normal files
Gamma and Alpha. This
option only has an effect if FancyIndexing
is
also enabled.
If these two options are used together, the server will include
HEIGHT
and WIDTH
attributes in
the IMG
HTML
tag for the file
icon. This allows the browser to precalculate the page layout without
waiting for all the images to load. If no value is given for the
option, it defaults to the standard height of the icons supplied with
the Apache software.
The NameWidth
keyword allows you to specify the
width of the filename column in bytes. If the keyword value is
*
, then the column is automatically sized to the
length of the longest filename in the display.
This enables the extraction of the title from HTML documents for
fancy indexing. If the file does not have a description given by
AddDescription
, then httpd
will read the document for the value of the TITLE tag. This is CPU
and disk intensive.
If specified, Apache will not make the column headings in a
FancyIndex
ed directory listing into links for
sorting. The default behavior is for them to be links; selecting the
column heading will sort the directory listing by the values in that
column. Only available in Apache 1.3 and later.
If the directory actually contains a file specified by the
HeaderName
directive, the module usually includes
the contents of the file after a standard HTML preamble
(<HTML>
, <HEAD>
,
etc.). The SuppressHTMLPreamble
option disables
this behavior, causing the module to start the display with the
header-file contents. The header file must contain appropriate HTML
instructions in this case. If there is no header file, the preamble
is generated as usual.
This will suppress the display of the last modification date in fancy-indexing listings.
This returns the Last-Modified
and ETag values for
the directory listed in the HTTP header. It is only valid if the
operating system and filesystem return legitimate stat(
)
results. Most Unix systems do so, as do
OS/2’s JFS and Win32’s NTFS
volumes. OS/2 and Win32 FAT volumes, for example, do not. Once this
feature is enabled, the client or proxy can track changes to the list
of files when they perform a HEAD request. Note some operating
systems correctly track new and removed files, but do not track
changes for sizes or dates of the files within the directory.
There are some noticeable differences in the behavior of this directive in recent (post-1.3.0) versions of Apache.
The default is that no options are enabled. If multiple
IndexOptions
could apply to a directory, then the
most specific one is taken complete; the options are not merged. For
example:
<Directory /web/docs> IndexOptions FancyIndexing </Directory> <Directory /web/docs/spec> IndexOptions ScanHTMLTitles </Directory>
In this case, only ScanHTMLTitles
will be set for
the /web/docs/spec directory.
Apache 1.3.3 introduced some significant changes in the handling of
IndexOptions
directives. In particular:
Multiple IndexOptions
directives for a single
directory are now merged together. The result of the previous example
will now be the equivalent of IndexOptions
FancyIndexing ScanHTMLTitles
.
The addition of the incremental syntax (i.e., prefixing keywords with
+ or -). Whenever a + or - prefixed keyword is encountered, it is
applied to the current IndexOptions
settings
(which may have been inherited from an upper-level directory).
However, whenever an unprefixed keyword is processed, it clears all
inherited options and any incremental settings encountered so far.
Consider the following example:
IndexOptions +ScanHTMLTitles -IconsAreLinks FancyIndexing IndexOptions +SuppressSize
The net effect is equivalent to IndexOptions FancyIndexing +SuppressSize
, because the unprefixed FancyIndexing
discarded the incremental keywords before it, but allowed them to start accumulating again afterward.
To set the IndexOptions
unconditionally for a particular directory — clearing the inherited settings — specify keywords without either + or - prefixes.