You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ravi Verma <ra...@telecommand.com> on 2008/12/18 08:18:57 UTC

Using AuthName with mod_rewrite

Dear Friends,

I am new to Apache and mod_rewrite. I have a challenge to append the
AuthName to the URL.

I am using the following directive to protect the location / with a popup
and user data coming from an LDAP server.

<Location />
      AuthzLDAPMethod ldap
      AuthzLDAPServer 10.2.1.86
      AuthzLDAPUserBase ou=People,dc=example,dc=com
      AuthzLDAPUserKey uid
      AuthzLDAPUserScope base
      AuthType Basic
      AuthName "GRRRR"
      require valid-user
</Location>

My email id ravi.verma@telecommand.com is a valid userid in the ldap server.

Now I need to write a rule so that I could rewrite / to an URL which looks
as follows.
http://localhost/home.seam?userid=ravi.verma@telecommand.com as I used
ravi.verma@telecommand.com as the valid-user.

When I use
RewriteEngine on
RewriteCond %{REMOTE_USER} ^
RewriteRule  ^/$   http://localhost/home.seam?userid=%{REMOTE_USER} [L]

All I get is
http://localhost/home.seam?userid=

I appreciate your help.

-- 
Kind regards.

Ravi Verma
Chief Executive Officer
Telecommand Software and Services
3175 Sunset Blvd, Suite 104-B
Rocklin, CA 95677
Phone:9167053261
Fax:9169142008
www.telecommand.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: Using AuthName with mod_rewrite

Posted by Ravi Verma <ra...@telecommand.com>.
Thank you Bob. Adding the following lines in the conf file made it work.

<Directory /var/www/html>
RewriteEngine on
RewriteRule  ^$ http://localhost/bob/ravi.html?userid=%{REMOTE_USER} [R,L]
</Directory>


Regards.

On Thu, December 18, 2008 3:19 am, Bob Ionescu wrote:
>> When I use
>> RewriteEngine on
>> RewriteCond %{REMOTE_USER} ^
>
> That RegEx is always true (so you can skip the condition). To check
> for at least one character present, use a '.', i.e.
> %{REMOTE_USER} .
>
> But anyway...
>
>> RewriteRule  ^/$   http://localhost/home.seam?userid=%{REMOTE_USER} [L]
>
> That is per-server context (which is a good idea to use) but auth and
> access checks are done on a per-directory basis. That means, that the
> ENV cannot be present in per-server context, i.e. before auth is being
> processed. There are two possible solutions:
>
> Use an URL-based subrequest in per-server context do determine the
> value of that ENV:
> RewriteRule  ^/$ http://localhost/home.seam?userid=%{LA-U:REMOTE_USER}
> [R,L]
>
> -or-
> use the rule in per-directory context
>
> <Directory /path/to/docroot>
> RewriteEngine on
> RewriteRule  ^$ http://localhost/home.seam?userid=%{REMOTE_USER} [R,L]
> </Directory>
>
> Bob
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


-- 
Kind regards.

Ravi Verma
Chief Executive Officer
Telecommand Software and Services
3175 Sunset Blvd, Suite 104-B
Rocklin, CA 95677
Phone:9167053261
Fax:9169142008
www.telecommand.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: Using AuthName with mod_rewrite

Posted by Bob Ionescu <bo...@googlemail.com>.
> When I use
> RewriteEngine on
> RewriteCond %{REMOTE_USER} ^

That RegEx is always true (so you can skip the condition). To check
for at least one character present, use a '.', i.e.
%{REMOTE_USER} .

But anyway...

> RewriteRule  ^/$   http://localhost/home.seam?userid=%{REMOTE_USER} [L]

That is per-server context (which is a good idea to use) but auth and
access checks are done on a per-directory basis. That means, that the
ENV cannot be present in per-server context, i.e. before auth is being
processed. There are two possible solutions:

Use an URL-based subrequest in per-server context do determine the
value of that ENV:
RewriteRule  ^/$ http://localhost/home.seam?userid=%{LA-U:REMOTE_USER} [R,L]

-or-
use the rule in per-directory context

<Directory /path/to/docroot>
RewriteEngine on
RewriteRule  ^$ http://localhost/home.seam?userid=%{REMOTE_USER} [R,L]
</Directory>

Bob

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org