# apache config: like mod_dir.so, but a Perl script



## Bill Evans at Mariposa (Jun 11, 2016)

I know about the `DirectoryIndex` statment ...

```
DirectoryIndex index.cgi index.html
```
... and that works fine for me (with index.cgi being a Perl script). But if, for a given directory, neither index.cgi nor index.html exists, I don't want to run `libexec/apache24/mod_dir.so`; I want to run a particular Perl script, and not have to place it (or a pointer to it) in each directory. How do I tell the apache config file that I want to fall back to an arbitrary Perl script if `DirectoryIndex` doesn't find one of the listed files in a particular directory?


----------



## xavi (Jun 11, 2016)

According to the Apache documentation at https://httpd.apache.org/docs/current/mod/mod_dir.html:

_Note that the documents do not need to be relative to the directory;_
DirectoryIndex index.html index.txt  /cgi-bin/index.pl
_would cause the CGI script /cgi-bin/index.pl to be executed if neither index.html or index.txt existed in a directory._


----------



## Bill Evans at Mariposa (Jun 13, 2016)

Bingo. What I'm trying for is something that displays in the style of Norton Commander / Midnight Commander: the desired directory is on the right, its parent directory is on the left, and you can click on file entries in either frame.  The format is similar to the output from `ls -l`. Proof of concept, which seems to run pretty well, is here.


----------

