title: Use mod_rewrite to create custom directory index in Apache
body: <p>So, Apache's default directory listing sucks and mod_autoindex's customisation options suck, so I figured I could write some rewrite rules in my server root to redirect any requests to a directory:</p>
  
  <pre><code>&lt;IfModule rewrite_module&gt;
      RewriteEngine on
      RewriteCond %{REQUEST_URI} -d
      RewriteRule .* /index.php?dir=$0
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Now, I get the impression this works at least a little, as turning off <code>indexes</code> still leaves <code>localhost</code> accessible (it displays the index.php), however it doesn't seem to reach subdirectories (which either revert to Apache's directory indexes if the <code>indexes</code> option is on, or give a <code>403</code> if they're off).</p>
  
  <p>My question is: can I get this rule to apply globally or is my quest for pretty directory indexes doomed to failure?</p>
  
  <p><strong>Edit</strong>: I should note: the above rules are contained in a <code>.htaccess</code> in the server root.</p>
  
  <p><strong>Edit</strong>: Ideally the solution, if it exists, would still have <code>DirectoryIndex</code> functionality (that is, <code>index.php</code> etc. will be displayed if it exists),</p>