Web File Listings

I finally made my web file listings integrate with my web site theme. Normally web file directories look pretty very ugly and this certainly was an improvement. Apache has built-in support for header and footer files to be wrapped around the file listing. You can even wrap PHP or other scripting languages around it if you configure Apache properly. I chose to use PHP as it can easily pull in template changes from the main site.

The first step is to make a template directory under your site root for the template. Then add your PHP files to the directory and make the following .htaccess file:


AddType text/html .php
AddHandler application/x-httpd-php .php
Options -indexes

The AddHandler statement tells Apache to process the PHP files when used as a template.

Next I added the Directory Indexing statements to the main .htaccess file under the root of the site:

Options +Indexes
IndexOptions +FancyIndexing +SuppressDescription +SuppressHTMLPreamble +XHTML
IndexOptions +FoldersFirst +IgnoreCase +NameWidth=*
HeaderName /source/theme/apache/header.php
ReadmeName /source/theme/apache/footer.php

And it works! You can see it in action at http://feisley.com/python/



One Response to “ Web File Listings ”

  1. Looks great. I have never really had a reason to do that, but it is very cool to find that it can be done if needed!

Leave a Reply