Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 =)

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Unfortunately this won't work for what I'm trying to do. I'm setting up a software mirror server for a few projects, quite a few folders have README.html files in, but not all of them so I wanted to set a 'default' ReadmeName to show up in those. –  sam Aug 2 '11 at 11:41
    
I just used different names in my example because I could. Set the server context to /README.html and the directory context to README.html that should do what you want. You still have to create the .htaccess files but that should be an easy script. –  Iain Aug 2 '11 at 11:53
    
Yeah I got that, but there are a lot of subdirectories (I'd guess hundreds, maybe thousands) to check, and I have to RSYNC with the delete option so I'd have to re-create them every time. Yes it's possible but I was hoping for an easyer solution –  sam Aug 2 '11 at 11:57
    
Also some of the directories have their own .htaccess files to set descriptions and non-standard ReadmeName's (I.E. for an entire directory and it's sub-directories) etc. so I'd have to check for that then append the ReadmeName on the end if needed. Not impossible but annoying –  sam Aug 2 '11 at 11:59
    
I hope someone can show us both an easier solution. –  Iain Aug 2 '11 at 11:59

Your Answer

 
discard

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.