Re: allow autoindex for a directory, but not for its subdirectories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Mon, Aug 23, 2010 at 3:51 PM, Freek Dijkstra <public@xxxxxxxxxxx> wrote:
[My apologies for the many posts; I just notices that my mailer removed
the <tags> thinking it was HTML]

Freek Dijkstra wrote:

> Curious,
> <Directory ~ "^/var/www/projects/.*$"> is never matched
> <Directory ~ "^/var/www/projects/.*"> is matched.
> Logically, I would have expected both regexps to yield the same result.

I did some more testing, and it just seems that the the end of line
anchor is just never matched. I can easily reproduce it with only a few
configuration lines (see below).

Is this a (known) bug or is there another explanation why I'm seeing
this behaviour? If this is intended behaviour, what configuration is
required to get the intended behaviour?


Steps to reproduce
1. Add the following configuration to httpd.conf:

Alias /test/ /var/www/test/

<Directory "/var/www/test/projects">
   Options Indexes
   Order deny,allow
   Deny from all
</Directory>

<Directory ~ "/var/www/test/projects/$">
   Allow from all
</Directory>


Expected results:
- requesting http://localhost/test/projects would give an autoindex
- requesting http://localhost/test/projects/subdir would give a 403
Forbidden

Actual results:
- requesting http://localhost/test/projects gives a 403 Forbidden
- requesting http://localhost/test/projects/subdir gives a 403 Forbidden

Regression:
1.
The following DirectoryMatch (without trailing /) gives the same result:
<Directory ~ "/var/www/test/projects$">
   Allow from all
</Directory>

2.
Adding an Allow from all for a specific subdirectory works as expected
(requesting the directory shows an autoindex):
<Directory "/var/www/test/projects/subdir1">
   Allow from all
</Directory>

3.
<Directory ~ "^/var/www/test/projects/.*$">
   Allow from all
</Directory>
results in 403 Forbidden for all requests. The DirectoryMatch is never
matched.

4.
<Directory ~ "^/var/www/test/projects/.*">
   Allow from all
</Directory>
results in autoindexes for all requests. The DirectoryMatch is always
matched, as expected.

5.
The regular expressions
"^/var/www/test/projects/.*$"
"^/var/www/test/projects/.*"
are logically the same. However Apache clearly treats them differently
(see 3 and 4 above). This seems like a bug to me.

6. Replacing the Directory directives with corresponding Location
directives gives the same result.


Notes:
1. Tested with Apache 2.2.9 on Linux, Apache 2.2.14 on Mac OS X and
Apache 2.2.15 on Mac OS X.
2. The note at
http://stackoverflow.com/questions/1665210/apache-config-exclude-subdirectories
indicates other people encounter this problem too. ("For some reason my
apache on Fedora 8 seems to be ignoring the end of line anchor in the
regular _expression_").

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux