20140510 apache directory indexes - plembo/onemoretech GitHub Wiki

title: Apache directory indexes link: https://onemoretech.wordpress.com/2014/05/10/apache-directory-indexes/ author: phil2nc description: post_id: 7562 created: 2014/05/10 15:19:52 created_gmt: 2014/05/10 19:19:52 comment_status: closed post_name: apache-directory-indexes status: publish post_type: post

Apache directory indexes

Sometimes you just want to publish a directory on the file system the easy way, which is why the mod_autoindex module for Apache exists. The simplest way to have Apache list a directory is to add the "Indexes" parameter to the Options directive inside the directory definition where listing is desired. Like this:

  Options FollowSymLinks Indexes MultiViews

Red Hat Enterprise and Fedora Linux come with a supplemental conf file that enables some (but nowhere near all) autoindex features (found at /etc/httpd/conf.d/autoindex.conf). Another way of controlling autoindex is to set various features up in an .htaccess file in the target directory. The default Red Hat config turns on FancyIndexing, which out of the box chops off the ends of long file names and inserts a continuation ("..>"). I find this extremely annoying, and unhelpful, when trying to navigate listings. To fix it all I had to do was add the "NamedWidth=*" parameter to the IndexOptions line in autoindex.conf, thus:

IndexOptions FancyIndexing HTMLTable VersionSort NameWidth=*

If you're like me and link to quite a few directory listings, you might want to set a "global" header for all those pages. Doing that requires a couple of adjustments to autoindex.conf, as well as creating a header and footer file. In the following example the directories I'm publishing are /data/install, symlinked to /var/www/html/install and /data/media, symlinked to /var/www/html/media. My primary stylesheet is the same main.css that features in my using a movie as a web page background. Edit autoindex.conf to change the text alongside ReadmeName and HeaderName, thus:

ReadmeName /include/FOOTER.html
HeaderName /include/HEADER.html

Now create those files under /var/www/html/include (or wherever your DocumentRoot points to). HEADER.html: [code language="html" gutter="false"]

<title>Casa Lembo</title>

Casa Lembo

Onemoretech Global News Current Time Media Streams Software Library Shared Media • [/code] And FOOTER.html: [code language="html" gutter="false"] [/code] Then restart Apache to make these changes effective. Test by going to one of the published directories and checking to see if the header displays.

Copyright 2004-2019 Phil Lembo

⚠️ **GitHub.com Fallback** ⚠️