Does anyone know if it's possible to use regex capture within Apache's DirectoryMatch directive? I'd like to do something like the following:
<DirectoryMatch ^/home/www/(.*)>
AuthType Basic
AuthName $1
AuthUserFile /etc/apache2/svn.passwd
Require group $1 admin
</DirectoryMatch>
but so far I've had no success.
Specifically, I'm trying to create a group-based HTTP Auth for individual directories/vhosts on a server in Apache 2.0.
For example, Site A, pointing to /home/www/a will be available to all users in group admin and group a, site b at /home/www/b will be available to all users in group admin and group b, etc. I'd like to keep everything based on the directory name so I can easily script adding htpasswd users to the correct groups and automate this as much as possible, but other suggestions for solving the problem are certainly welcome.
You could tackle the problem from a completely different angle: enable the perl module and you can include a little perl script in your httpd.conf. You could then do something like this:
<Perl>
my @groups = qw/ foo bar baz /;
foreach ( @groups ) {
push @PerlConfig, qq| <Directory /home/www/$_> blah </Directory> |;
}
</Perl>
That way, you could even read your groups and other information from a database or by simply globbing /home/www or whatever else tickles your fancy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With