Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Apache and I'm getting really tired of editing hundreds of files which are all named index.html. What I'd like is something like this:

    DirectoryIndex: foo.html

    DirectoryIndex: bar.html

    DirectoryIndex: narf.html

...but automatically, for all of my directories. Is there a way to do this in Apache?

share|improve this question

migrated from Dec 20 '10 at 0:28

This question came from our site for pro webmasters. would suggest not, but I can't help wondering why you're going about it the way you are... – Andy Smith Dec 20 '10 at 1:00 the moment my text editor has five tabs open that are all named "index.html", which is not terribly easy to navigate. I'm not really wedded to using DirectoryIndex if there's a better way to accomplish this. – Ender Dec 20 '10 at 1:43
Have you considered using a text editor that allows you to use most of the path name in the tabs? Or not having each directory contain an index.html file that you actively work with? – Andrew M. Dec 20 '10 at 5:12
up vote 1 down vote accepted

From your comment that you're not wedded to the idea of DirectoryIndex, I bet you could accomplish the same feat with mod_rewrite. Something like

RewriteCond %{REQUEST_FILENAME} !-f               
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^/(.*)/(.*)$$1/$2/$2.html [L]

The above isn't tested, just a general idea that you want to get the entire path and supply the last folder name as the .html file if the requested filename doesn't exist. As I said not tested out for exact syntax for getting the directory path.

share|improve this answer

Your Answer


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.