Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am looking to modify the HTML that apache generates for its default directory listing.

I already know how to create a HEADER.html file that gets included for every directory listing. I am attempting to change the actual html that Apache generates for the file listing itself; right now my MacOS apache generates this for example:

<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="ios-prototype/">ios-prototype/</a>         </td><td align="right">07-Dec-2012 16:47  </td><td align="right">  - </td><td>&nbsp;</td></tr>
<tr><td valign="top"><img src="/icons/folder.gif" alt="[DIR]"></td><td><a href="magneto-git/">magneto-git/</a>           </td><td align="right">07-Dec-2012 16:46  </td><td align="right">  - </td><td>&nbsp;</td></tr>
<tr><th colspan="5"><hr></th></tr>
</table>

I want a different HTML structure (like, say, an OL) generated when my server spits back directory listings. (FYI I'm doing a bunch of mobile browser prototyping with my local webserver & need to make it not totally horrible to browse with fingers to the right test directory — the table structure sucks, and while I can mod a lot of it with CSS it's still going to be ganky.)

share|improve this question
    
You may get an answer here but I recommend asking on the apache mailing list. –  barlop Dec 8 '12 at 1:36
    
My guess is it's going to be in the source of Apache itself. Have you checked it yet? –  Ƭᴇcʜιᴇ007 Dec 8 '12 at 2:57
    
@techie007 No idea how to check Apache's source code without very specific instructions. Weird that it's buried rather than in some sort of config file. –  Ellen B Dec 10 '12 at 18:39
    
Download the source from Apache's web site, open it in a text editor and start searching. :) –  Ƭᴇcʜιᴇ007 Dec 10 '12 at 19:48

1 Answer 1

I understand your question as "How do I customize the directory listing page shown by Apache when there is no index file?"

If I'm correct, this link has the instructions: http://perishablepress.com/better-default-directory-views-with-htaccess/

Quick directions are:

1) Edit the site config (example: /etc/apache2/sites-available/default) and add these lines between the lines:

Options +Indexes

IndexOptions FancyIndexing IgnoreCase VersionSort SuppressHTMLPreamble

HeaderName /relative/path/to/header.html

(The header.html will be loaded based on the current BROWSED directory. With these instructions you'll need to have a header.html in each directory you want to customize. You can also choose to do it only for one directory using .htaccess)

2) Reload Apache (sudo /etc/init.d/apache2 reload)

3) Create the header.html file in the desired directory. There is example code and style in the link (since I can't paste code here).

Reload your page in your browser and you it should be customized. I tested both of these on Ubuntu 12.04 just now.

Edit: I've changed this answer significantly, so Ellen B's comment no longer applies, sorry. It's a better answer, though, and tested.)

share|improve this answer
    
Huh. So this is using XSL [kill me now] that the browser will transform into whatever HTML I want? I already know about the header.html — the problem is that something deep in Apache is spitting out a TABLE HTML element and I don't want it to. I may check this out but it's prob not worth the time to mess with XSL for me... –  Ellen B Dec 10 '12 at 18:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.