Forum Moderators: phranque

Message Too Old, No Replies

Directory container rule to Index sub-dir tree

Apache index sub-dir rule httpd.conf

         

Sosthenes

2:32 pm on Sep 23, 2004 (gmt 0)

10+ Year Member



Hi there.

I have set up .http.conf to only allow access to specific sub directories in my server document path.(By default all Index Options are set to off.)

A user should be 'locked' into a specific directory, and not allowed access further up, or down, the directory tree.

However, I would like to set up another sub directory in the document path, so I can publish other documents on my server for public use, and enable directory listings of that sub directory, and all sub dirs contained below that.

I would like to write just one rule that would turn Indexing on for that particular sub dir, AND all sub dirs below that.

The following rule allows indexing of the specified subdir_a, but does not seem to affect any sub dirs below it.

<Directory "/path/to/server/doc_root/subdir_a">
Options None
Options Indexes
Order deny,allow
Allow from all
</Directory>

How can I set up the rule to apply to all sub dirs below subdir_a , so that users can have directory Indexing turned on, for sub dirs below subdir_a, without me having to explicitly mention the other sub-dirs by name?

Would this be a job for REG EX's in the directory container?

TIA - Sosthenes

jdMorgan

3:27 pm on Sep 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sosthenes,

Welcome to WebmasterWorld!

According to the Apache documentation, <Directory> encloses a group of rules which will apply to the named directory and all sub-directories of that directory. So, the code you have written should work, unless there are other <Directory> directives which also match the prefix name of subdir_a, or directives in .htaccess files in subdir_a and its subdirectories.

If you have conflicting rules because of naming similarities between public and non-public paths, take a look at using extended regular expressions instead of prefix-matching, and also consider using <DriectoryMatch>. Both of these options will provide more flexibility than using prefix-matching with <Directory>.

Another thing that can interfere with correct results is that you must flush your browser cache (Temporary Internet Files) and any other local caches before testing any change to httpd.conf or .htaccess that affects access control. Otherwise the previously-cached response will be returned, and it will look like your changes had no effect.

Jim

Sosthenes

7:05 pm on Sep 27, 2004 (gmt 0)

10+ Year Member



Hi Jim - thankyou for your help.

Got it working now!

Using the following rule:

<Directory "/path/to/server/docs/pub/">
Options None
Options Indexes
Order deny,allow
Allow from all
</Directory>

This will automatically generate an Index of the 'pub' sub-dir, and all sub-dirs below that.

I think the problem was I had no docs in the sub directories below pub - was in a bit of a hurry!

Set up some test docs and got the Indexing going OK.

Then had problems accessing each file in the directory. The permissions were rw- --- ---

Had to set the permissions on the files to
rw- r-- r-- this enabled me to generate the directory listings, and view the contents of each listed file.

Also had to do an apachectl stop, apachectl start, to bring the new .httpd.conf configuration into play.

Thanks again - Sosthenes