You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ed...@cpd.ufrgs.br on 2005/01/19 20:49:36 UTC

[users@httpd] DirectoryMatch - how to use the matched substring ?

Hi.

	I am trying to implement a Webdisk-like service to the University where I work
using Apache + mod_dav + mod_auth_ldap. The basic part is all set, with the
authentication working and the DAV part too.

	The problem I am facing now is as follows:

	The regular expressions are not expanded (using $1, ...) when using
DirectoryMatch. As a way (the only one that I can see) to avoid using .htaccess
files, I would need to use regex expansion to make the Directory information in
httpd.conf generic/dynamic.
	The basic path can be seen as: /home/user/.
	The thing is, only the 'user' has permission to access his home, and there will
be some thousands of them..

	My idea is to use something like:

	<DirectoryMatch /home/([^/].*)/>

	...
	require user $1

	</DirectoryMatch>

	But, $1 does not expand to the matched part of the regex (user). I tried to
search the archives, google, etc, but found nothing. Any ideas ?

	It does not seem feasible to use 1000 Directory entries, with its specific
"require user xxx" inside the httpd.conf file, and reload Apache each time a
user is added or removed. In that case, .htaccess seems better..
	If anyone has another solution (some magic module, maybe ?), I would like to
know.

Thanks in advance.

--eduardoh

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] DirectoryMatch - how to use the matched substring ?

Posted by Joshua Slive <js...@gmail.com>.
On Wed, 19 Jan 2005 17:49:36 -0200, eduardoh@cpd.ufrgs.br
<ed...@cpd.ufrgs.br> wrote:
> Hi.
> 
>        I am trying to implement a Webdisk-like service to the University where I work
> using Apache + mod_dav + mod_auth_ldap. The basic part is all set, with the
> authentication working and the DAV part too.
> 
>        The problem I am facing now is as follows:
> 
>        The regular expressions are not expanded (using $1, ...) when using
> DirectoryMatch. As a way (the only one that I can see) to avoid using .htaccess
> files, I would need to use regex expansion to make the Directory information in
> httpd.conf generic/dynamic.
>        The basic path can be seen as: /home/user/.
>        The thing is, only the 'user' has permission to access his home, and there will
> be some thousands of them..
> 
>        My idea is to use something like:
> 
>        <DirectoryMatch /home/([^/].*)/>
> 
>        ...
>        require user $1
> 
>        </DirectoryMatch>

No, you can't do that.

In 1.3 there is "require file-owner", but it has never been ported to
2.0 as far as I know, and I doubt it would work with ldap anyway.

One option is you could use mod_rewrite to automatically place people
in their home directories when they login.  Something like:

<Directory /home>
Require valid-user
</Directory>
RewriteEngine On
RewriteRule %{LA-U:REMOTE_USER} (.+)
RerwiteRule ^/webdisk /home/%1

Joshua.

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org