4

Is there a way to get an array (or something similar) of the DirectoryIndex in PHP being run under Apache? For example, I would like to be able check if one of the DirectoryIndex files exist in a specific directory. This is related to How can I get the DirectoryIndex filename for a given URI using PHP? but it doesn't quite ask the same thing so please don't point to it despite its similarity.

EDIT: I'd prefer not to have to go file parsing.

Tyler Crompton
  • 11,740
  • 12
  • 59
  • 91

2 Answers2

4

Unfortunately not, as Apache does not make it available through environment variables.

If you have control over the configuration you could use the setenv directive alongside DirectoryIndex. Then read it in PHP using apache_getenv().

Otherwise I think you'll have to parse the Apache config files yourself.

Tak
  • 10,344
  • 5
  • 26
  • 47
0

You can get the DirectoryIndex this way:

basename(apache_lookup_uri(realpath(urlencode('Path_directory_here')))->uri);

This method only works with Apache DSO module running.