Before and after screens. Click for a big version.

Before and after screens. Click for a big version.

Download (v1.1, sept 1 2009)

Apache’s default directory index pages are ugly. Indices is a set of hacks that makes them pretty, and more usable.

View a demo index here.

What it does

  • Simple, clean design
  • Easily customizable logo and link at the top
  • Optional readme.html file inserted before file list
  • Long filenames are visible
  • Directory names in bold; trailing slashes stripped from directory names
  • Nice file icons
  • Output is XHTML 1.0 Strict, styled with CSS
  • Should be easy to modify for your own needs

How it works

Unlike other PHP-based solutions, Indices is based on Apache’s built-in directory mechanism, so it’s pretty easy to seamlessly integrate it into your entire website.

Indices uses a few helpful Apache mod_autoindex directives, coupled with a bit of CSS and (optional) Javascript hackery. The README talks about installation and how everything works.

If you’re curious about the plumbing, read this blog post.


I developed Indices for my web server, which runs Apache 2.0.x and PHP 5.1.x. It’ll probably require some tweaking to get it working with earlier versions of either.

If you’re running Apache 1, you’ll be able to use some of this code for inspiration, but you’ll need to do a lot more hackery.


Download (v1.1, sept 1 2009)

38 Comments so far

  1. Adrian January 12th, 2010 2:58 pm

    I love this as it’s very easy to use and is non-intrusive. Nicely done.

    Just a point about the README – it may be useful to add that if you are installing this to a directory that is not under the htdocs path using the Directory directive, you need to include the line:

    AllowOverride Indexes Options

    Thanks for sharing your excellent solution.

  2. Steve January 18th, 2010 10:25 am

    Is there anyway to specify folders or files to omit from the directory listing?

  3. gse January 18th, 2010 11:06 pm

    @Steve – That kind of thing should be done with Apache configuration; Indices’ purpose is to style Apache’s output.

  4. Steve January 25th, 2010 9:39 pm

    @gse – Thanks. I should have searched Google first. IndexIgnore is what I needed.

  5. Paul D February 14th, 2010 1:58 pm

    I had to include ‘FileInfo’ to my AllowOverride directive to supress the ‘AddType not allowed here” error. So my line would look like:

    AllowOverride Indexes Options FileInfo

  6. bharris February 19th, 2010 8:50 am

    For some reason on my CentOS 5.4 system I had to turn on short_open_tag for indices to operate properly. I ended up just adding:
    php_flag short_open_tag on
    …to the start of the .htaccess file.

    Thanks for your effort in a great bit of code.

  7. deadelvis February 22nd, 2010 2:25 am

    Too bad “.. parent directory” link and/or arrow does not show! :(

    Couldn’t figure out how to fix it either.

  8. deadelvis February 22nd, 2010 2:34 am

    Nevermind… figured it out. It’s just hidden in the CSS. Bad call if you ask me.

    Thx for the nice work with this!

  9. adlwtn March 12th, 2010 10:47 am

    I did everything as the instructions say… yet it doesn’t seem to do anything. I added the indices directory to my website’s root directory, and renamed main-htaccess to .htaccess (i had nothing in my .htaccess previously so it shouldn’t cause an issue).

    Do I need to modify my httpd.conf file? Because that’s empty for me.

    Sorry, I’m newish to the whole apache2 thing.

  10. gse March 22nd, 2010 7:49 pm

    @adlwtn – Hard to say what’s going on. Be sure you have htaccess files enabled in your Apache config? Maybe ask a friend who’s an Apache expert to help you out. Sorry but I don’t have much time to support Indices.

  11. Imran-UK April 22nd, 2010 3:20 am


    The zip contains a subdir called indices, make sure that and not the indices-1.1 is in your docroot.

    The .htaccess file should be copied to the directory you’re planning to pretty index.

    Odd that you’re main Apache config is blank. Double-check this. Normally /etc/apache2/apache2.conf on modern Linux-systems. The other possibility is that the main config file, or vhost file/config, has “AllowOveride None” somewhere as this would preclude the use of .htaccess files.

    Generally I think it is better to use the main config file rather than .htaccess unless there is a good reason not to.

    @gse – thanks very much for writing this. I sent an email just now with some feedback.

  12. Matthew June 28th, 2010 11:00 am

    Wanted to thank you. I’ve been using this for some time now and it really pretties up the mess.

  13. tom June 30th, 2010 12:21 am


    Thanks for sharing this wonderful code!

    I’ve added the code as described.

    # In order for the PHP file to execute in a header, need to have a major type of text
    AddType text/html .php
    AddHandler application/x-httpd-php .php
    Options -Indexes

    Everything is working except, there’s always one folder missing. It’s always the first folder on top. When I sort folders by name it’s just the opposite. The first folder is visible and the last folder is hidden. Is there anything I can do?

  14. Cristian Granados July 2nd, 2010 9:31 am

    Thanks, it works wonderful!
    To make a parent directory link just add:
    <a href="../">Parent Directory</a>
    in the header.php file, in to the body section. You can custumize the aparence with css

    Pura Vida Costa Rica!

  15. Jordan July 25th, 2010 7:32 pm

    Tom: Your problem might be that the css specifies that the first row of the table shouldn’t be shown. I ripped out the static CSS because I was having problems with php, and i noticed the same thing. I imagine the php file itself is supposed to determine when it’s in the root of the domain (therefore there’s no parent directory link) and not include that CSS, but it’s probably broken for you.

    Hmm, then again, that might not be it since if you reverse sort it does the opposite behavior? Not sure, but maybe it will help…

  16. jwzumwalt September 23rd, 2010 10:27 am

    I am using Indices on my “local” development work station and on my website. I have different issues with both; so there must be some apache conf issues. Fore example, I got my “local” working except the parent directory link does not show… my workstation shows the parent link but the css definitions don’t work. Both use the same setup!

    Anyway, here are a few pointers…

    1) Steve… you can control directories and files that apache displays with the following command,
    IndexIgnore .htaccess readme.html dir.txt “!*”

    The above line obviously does not include the three specific files given by name. The last definition “!*” will not display a file or directory that starts with an exclamation mark – which is how I had my private information.

    2) If your .htaccess is setup in your doc root, *** remove the .htaccess in the “indices” folder *** or they will have conflicts.

    As I wade through this experience and learn things, I will leave comments, and would appreciate if others would do the same :)

  17. Paata December 20th, 2010 12:51 pm

    So simple & cool with your help, serious work, many thanks !

  18. Roberto December 21st, 2010 8:14 am

    I am trying to use it on Ubuntu 10.04 LTS:

    I can get something working (i.e. icons) but I need to AllowOverride All on the directory and I do not get the nice box, fonts and highlighting :(

    any hint?

  19. Anthony February 9th, 2011 1:44 am

    thanks for a great tool, got this working on a few places now

    if a directory before had its own header.html file, how can we get it to include this info or overide the default indices info?

  20. MagoNicola May 23rd, 2011 8:31 am


    first of all, great job!

    I have some problems on my website, I follower instructions (extract zip file in root) but this is the result:
    Why I have “php code” embedded in my HTML?


  21. MagoNicola May 24th, 2011 1:41 am

    In particular, seems that header..php and readme.php are found but are called like Static HTML files and not processed by php preprocessor….

  22. superbarney June 26th, 2011 3:36 pm

    Hi there! Does this work out of the box with Apache 2.2.x?

  23. gse June 26th, 2011 11:55 pm

    No idea, but it’s easy to try it and see. Probably.

  24. Fierce July 20th, 2011 4:59 pm

    any idea on how to get this to work on a mac with MAMP 2.0?

    I moved indices to /extras and modified /extras/httpd-autoindex.conf and nothing happened.


  25. gse July 21st, 2011 7:10 pm

    No ideas, sorry. (I don’t really “support” this — it’s pretty much up to folks to figure out how to make it work when it doesn’t.)

  26. webmasta August 4th, 2011 2:51 pm

    This is excellent! I couldn’t read the full file names or the directory names, but now everything is cleaned up. I’ve gotten the icons working, but for some reason, the header is not functioning. I used absolute URLs for the paths of all of the icons, and have tried relative AND absolute URLs for the header and footer files, but to no avail. Anyone have an idea of why that might not work? I know PHP is running on the server and all that …

    Thanks in advance.

  27. Antonio Bonifati August 12th, 2011 7:20 am

    Hi Scott,
    I had to change all PHP open short tags into header.php



    <?php echo

    since my installation does not support them.
    Btw this is another reason I hate XML :)


  28. ashorlivs September 26th, 2011 4:44 pm

    +1 with Antonio

  29. LawrenceR December 14th, 2011 9:50 pm

    This rocks. I idly downloaded it, read and followed the README, hit a directory that gives a directory list, and wham! a neat listing in Arial. I dumped the .htaccess file in a virtual directory that does directory browsing and it even worked there. This is on a XP box running XAMPP, with scarcely any configuration post-install. Love it!

  30. Keith H January 25th, 2012 2:04 pm

    Vewy vewy pwitty!

    I’m sure there’s a nice way from the htaccess directory to hide the /indices folder, no?

    Not knowing the “right” way to do it, I renamed indices to .indices and changed all the paths in .htaccess accordingly.

    Thanks for putting this out there. Turns a hackey file browser into something much more livable.


  31. Trentster February 9th, 2012 3:45 am

    This is very cool. Just wondering if you have managed to get it to show a default favicon.ico , I have tried everything I can think of.

    Any ideas

  32. NSError February 9th, 2012 1:42 pm

    I did some major hackery of this, including translating the JS to jQuery (which is slightly more cross-browser) and I also migrated almost all the CSS to use CSS3 selectors instead of tacking a bunch of classes into the DOM tree. I also decided to move the JS and CSS into their own files so that browser caching can reduce the amount of bandwidth used to download them. I put my alterations up on Github:

    Tested in Safari 5, Opera, FF10, and IE9 and it seems to work OK.

    Hopefully someone finds something there they like. (Otherwise, works for me so I’m happy).

  33. gse February 9th, 2012 1:48 pm

    Holy crap, that is great! I’ll update this page to point at yours when I have a chance.

  34. Bonsailinse August 20th, 2012 1:18 pm

    Hi there.

    Is there any way you could translate the whole htaccess into an instruction to use with nginx?

    That would be great.

    Thank you very much,

  35. Christian September 5th, 2012 1:32 am

    Great piece of code – thank you for sharing!

  36. Jonah Petri November 13th, 2012 7:25 pm

    Great little piece of code. In order to get header.php to run on my hosting service’s server, I needed to use the following line as my AddHandler line:

    AddHandler application/x-httpd-php5 .php

    Just wanted to record that for posterity :) Thanks again.

  37. Mike November 18th, 2012 3:12 pm

    Using Apache 2.2.x. I snagged NSerror’s version and changed the /indices/.htaccess to use:

    Options -Indexes

    SetHandler application/x-httpd-php


  38. Athtsa December 20th, 2012 12:17 pm

    Hello!Thank you for your effort!
    Is there any way of traslating or changing the header row cells from the table? I mean the Name , Last Modified, Size. I want to show this 3 strings to another language.
    Thank you