how to rewrite to a userdir after authentication

Discuss practical ways rearrange URLs using mod_rewrite.

how to rewrite to a userdir after authentication

Postby guest » Tue Feb 11, 2003 4:30 pm

We need to _rewrite_ a URL (same for all users) to be served from a user's directory particular for each user, leaving the url in the browser unchanged. As the goal we want to emulate somehow FTP access but with WebDAV (mod_dav).

So is there any way to accomplish this?
Could it be equally accessible with WebFolders using mod_dav?

Below is the description of taken approach:
ASH
===========================================

=PROBLEM=

All users are presented the same URL:

http://myserv/servdir/

We need to:

1) authenticate the user
2) rewrite URL to be served from off-docroot userdir:

servdir/(.*) --> /u/userdir/(.*)

where:
userdir=MAP(user)

NOTE:
1) servdir/ doesn't exist per se under myserv DOCUMENT_ROOT.
2) the resulting URL shown in the browser remains the same as the initial one:
http://myserv/servdir/

============================================

=APPROACH TAKEN=

??URL: http://myserv/servdir/ --AUTH--> /u/userdirMAP(user)/(.*)

in HTTPD.CONF

<VirtualHost IP >
{... myserv config ...}
RewriteMap user-to-dir txt:/path/userdirmap.txt

<Location /servdir>
{... Options, Auth ...}
RewriteEngine On
RewriteCond %{REMOTE_USER} !^$
RewriteCond %{DOCUMENT_ROOT}/servdir !-d
RewriteRule servdir/?(.*) ${user-to-dir:%{REMOTE_USER}}/$1 [L]

</Location>
</VirtualHost>
==============================================

=RESULTS=

1) It works but strangely -- in WebFolders it shows along with the contents of the /u/userdir
a sub-directory servdir/ as though it were a subdir of /u/userdir, which it's NOT.
-----------
/u/userdir/:
{...userdir files...}
servdir/
-----------
2) attempting to browse the servdir/ fails (as it should since it doesn't exist)

==============================================
guest
 

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 2 guests

cron