httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Dalton <steve.dal...@gmail.com>
Subject Re: [users@httpd] How to serve up different content depending on authenticated user
Date Thu, 05 Feb 2009 08:01:09 GMT
Thanks guys
I managed to do something similar in the end, using the prefix user_ for
each user directory then adding .htaccess to root dir of:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /var/www/passwd/htpasswd
Require valid-user

RewriteEngine on
RewriteCond $1 !^user_
RewriteCond %{REMOTE_USER} ^([a-z0-9_]+)$
RewriteRule (.*) /var/www/accesstest/user_%1/$1 [

The only problem with this is that any user could access other users
directories... so I then had to add an additional .htaccess of

require user spidie

to the user_spidie directory... etc etc.

Hopefully there is a better way to automate this - I don't like the extra
.htaccess as if the file accidentally gets deleted the directory is open to
valid users again.

Steve

On Thu, Feb 5, 2009 at 5:44 PM, André Warnier <aw@ice-sa.com> wrote:

> Matt McCutchen wrote:
>
>> On Thu, 2009-02-05 at 15:13 +1000, Steve Dalton wrote:
>>
>>> I'm running apache 2.2 on Ubuntu and I need to serve up a different
>>> directory depending on the user that is authorised with the server.
>>> I've check the mailing list and apache docs but haven't found much so
>>> far - I may just not have the proper search terms though (I don't know
>>> how best to describe it)
>>>
>>> eg.
>>>
>>> http://spidie@foo.com -> /var/www/private/spidie
>>> http://fred@foo.com -> /var/www/private/fred
>>>
>>
>> How about this:
>>
>> RewriteEngine On
>> RewriteRule ^(.*)$ /var/www/private/%{REMOTE_USER}/$1
>>
>>  The above assuming that indeed the users are "authorised" (or rather in
> this case "authenticated") by the time the rule kicks in.
> But since the users can only be authenticated based on some "Auth..."
> section with a "Require ..." , where would these rules be ?
> Isn't there some chicken-and-egg situation there ?
>
>
>
>
>
>
> ---------------------------------------------------------------------
> 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
>
>


-- 
I did have a signature, but the dog ate it.

google:steve.dalton | skype:spidieman | msn: msn@steve.dalts.net |
yahoo:daltonsp | aol: spidie100 | twitter: @spidie | mynetfone:09203861

Mime
View raw message