Change default ReadmeName in Apache

apache-2.2directoryindex

How do I change the default ReadmeName for Apache directory indexes?

I have a readme file in the root of my site example.com/README.html which I want to display as the readme file for Apache directory indexes unless the directory has it's own README.html file. Is this possible?

Example;
With the directory structure

-/
-/folder1/
-/folder1/README.html
-/folder2/
-/README.html

example.com/ should display example.com/README.html in it's directory index,
example.com/folder1/ should display example.com/folder1/README.html,
example.com/folder2/ should display example.com/README.html

I can set

ReadmeName README.html

in my config, but that will display "Apache Server at example.com Port 80" in the footer of the directory index for example.com/folder2/
Likewise I can set

ReadmeName /README.html

but that will ignore the README.html in folder1/

Did any of that make sense? I'm not doing very well to explain this =)

Best Answer

I don't think you can do this globally. You can though specify a ReadmeName in the vhost/server context which points to a server wide file e.g.

<VirtualHost *80>
    .
    .
    ReadmeName    /README.html
<Virtualhost>

This can be overridden per directory with a .htaccess file

ReadmeName README.html

From the Documentation

Both HeaderName and ReadmeName now treat Filename as a URI path relative to the one used to access the directory being indexed. If Filename begins with a slash, it will be taken to be relative to the DocumentRoot.

This works on an Ubuntu system I have to hand.

Related Topic