LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to add a new parameter with rewrite in Apache? (http://www.linuxquestions.org/questions/linux-server-73/how-to-add-a-new-parameter-with-rewrite-in-apache-935371/)

Felipe 03-19-2012 06:23 PM

How to add a new parameter with rewrite in Apache?
 
Hallo.

Apache/2.2/Tomcat6 on Centos 5.5.

I authenticate users in Apache using kerberos. In tomcat I can recover user using next configuration in Apache:

...
AuthType Kerberos
AuthName Autenticacion
require valid-user

RewriteEngine On
RewriteRule .* - [E=RU:%{REMOTE_USER}]
RequestHeader set X_REMOTE_USER %{RU}e

But I'd like to send user in a parameter:

Ex:
If receive /application/login.jsp

Apache will rewrite the query and send Tomcat:

/application/login.jsp?user=username

I've tried with rewrite:

RewriteEngine on
RewriteRule /application/login\.jsp /application/login.jsp?user=%{X_REMOTE_USER}e

But it doesn't work.

Whats wrong in the rule?

Thanks

Felipe 03-26-2012 04:49 PM

Finally, I've found the solution:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^/(.*)/login\.jsp$ /$1/login.jsp?user=%{LA-U:REMOTE_USER} [PT]

</IfModule>


All times are GMT -5. The time now is 06:41 AM.