Score:0

In Apache2, how can I can the file contents for an index.html in subdirectories when I do not explicitly request it?

cn flag

For blarg.com This is the tree under the document root:

/index.html -/foo/index.html -/foo/bar/index.html

If the request is for 'http://blarg.com' then index.html is returned without issue.

However, a 404 is returned when the request is for '/foo/' or '/foo/bar'.

A response 200 is returned for '/foo/index.html' and 'foo/bar/index.html'.

This is the configured directive:

DirectoryIndex index.php index.html

I would like to get a 200 and the contents of the index.html when the browser requests '/foo' or '/foo/'.

Now, I can get what I want if I change the directive configuation to:

DirectoryIndex index.html

However, I want the option to have an index.php in some subdirectories.

How can I have my cake and eat it too?

Chris avatar
it flag
Do you get a 404 if the request is `/foo` and `/foo/` ? The default configuration should work. I suspect a missing trailing slash, required for `DirectoryIndex` directive to work *The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory* ***by specifying a / at the end*** *of the directory name.*
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.