views:

306

answers:

2

Is there a way to apply a rule to a single directory and not its subdirectories without using .htaccess files? I want /var/www/html to order by the Date desc. However, in the subdirectories, I don't want this rule applied.

Right now, I have IndexOrderDefault Descending Date within the /var/www/html Directory tag.

+2  A: 

You can use the DirectoryMatch directive to match that directory (and only that directory) exactly:

<DirectoryMatch "^/www/var/html$">
    IndexOrderDefault Descending Date
</DirectoryMatch>

It uses regular expressions to match the directory path. See http://httpd.apache.org/docs/2.0/mod/core.html#directorymatch for more info.

richleland
Yeah, everything I've read points to this being the best way to do it. For some reason my apache on Fedora 8 seems to be ignoring the end of line anchor in the regular expression. I'll try it on my Centos box when I get a chance, and if it works, I'll give you the credit.
Chris
+1  A: 

For users who encounter this problem: See https://issues.apache.org/bugzilla/show_bug.cgi?id=49809 (Apache bug 49809). $ is not recognized by Apache as an end of line anchor for some inexplicable reason.

Freek Dijkstra
Great followup. I wish I had the time to look into it a while back. I remember banging my head against the wall on this one!
Chris