2

Is it possible to make an Apache server like this

Apache/1.3.41 Server at user.it.uu.se Port 80

display hidden files (i.e., those who start with a dot) in a specific directory? I have some configuration there that's accessible (no problem), only those files don't show when I navigate to that directory. (Of course, you could set up an HTML interface with links, etc., even automatize update, but I'd rather just view the files like any others.)

It's my school's server, so I can't configure it apart from putting a file in that directory, telling the server to override the habit of not showing hidden files. Is this something you normally do, and, if so, how?

The system, if it matters (with uname -a):

SunOS yxan.it.uu.se 5.10 Generic_147440-25 sun4u sparc SUNW,Sun-Fire-V240
1
  • 1
    I thought I'd tell you, this answer shows that this is indeed possible to configure (probably in /etc/apache2/conf.d/httpd.conf). But, I don't know how to add that as a "local exception" as is the case in my question. Commented Dec 26, 2012 at 21:08

3 Answers 3

1

You can't remove files from the IndexIgnore in a local directory. But you can remove them from the global IndexIgnore line, and then use a second IndexIgnore directive inside the <Directory> context for those directories where you do want to keep the files hidden.

Here are the docs for mod_autoindex.

1
  • OK, how about giving me an example (at least) to modify so I can try it? If it works, I'll accept your answer because it really is an answer, not a workaround as the solution I provided. Commented Mar 1, 2013 at 22:11
0

Judging by the source code, it looks like it's hard coded to ignore dot files.

http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/src/modules/standard/mod_autoindex.c

if ((name[0] == '.') && (!name[1])) {
return (NULL);
}

Maybe someone else can tell differently...

3
  • 3
    Hm, isn't that to ignore the current directory? Or what else do you make of the (!name[1]) part? Commented Nov 15, 2012 at 3:48
  • You very well may be right, but I think there's a different section earlier on dealing with that. Although admittedly, I'm no expert with C. Commented Nov 15, 2012 at 3:52
  • Emanuel, that's just for the current directory as you said. Commented Feb 21, 2013 at 10:23
0

This PHP workaround does it:

<?php
   if ($handle = opendir('.')) {
     while (false !== ($entry = readdir($handle))) {
       if ($entry != "." && $entry != ".." &&
           $entry != "index.php") {
         echo "<p><a href='$entry'>$entry</a></p>";
       }
     }
     closedir($handle);
   }
?>

See it in action here.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.