Display a Standard Header and Footer on Directory Listings
Problem
You want to display a header above and a footer below your directory listing.
Solution
# Remove the standard HTML header, if desired IndexOptions +SuppressHTMLPreamble HeaderName /includes/header.html ReadmeName /includes/footer.html
Discussion
The directives HeaderName and ReadmeName specify the URI of files to be used as a header and footer, respectively, for directory listings.
If your HeaderName file
contains an HTML <head> tag,
<title> tag, or other things
associated with the start of an HTML document, you will want to use
the IndexOptions
+SuppressHTMLPreamble directive to disable mod_autoindex’s automatically generated
HTML heading. Failure to do so will result in an HTML document with
two heading elements, with the result that any heading attributes set
in your header will probably be ignored by the browser.
The argument to both HeaderName and ReadmeName is a URI relative to the current directory. That is, if there is no leading slash, it is interpreted as a path relative to the current directory, but if there is a leading slash, it is interpreted as a URI path—that is, relative to the DocumentRoot.
Your HeaderName and ReadmeName can be arbitrarily complex to
produce whatever page layout you like wrapped around the
auto-generated directory listing. You could, for example, open
<table> or <div> sections in the header, which
you then close in the footer, in order to produce page layout
effects.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access