httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis GALIEGUE <...@one2team.com>
Subject [users@httpd] Ampersand extends to the left part of regexes with RewriteRule, RedirectMatch and SetEnvIf: is that expected?
Date Fri, 04 Dec 2009 08:55:51 GMT
Hello everyone,

I've had the request to redirect a particular URI, say /foo or /foo/
to http://some.external.site/?var1=val1&var2=val2&var3=val3. The
Apache server version is 2.0.52 used on RHEL 4.x. I have tested with
2.2.3 on RHEL 5.x and the behaviour below is the same...

This looked quite simple, so I tried this:

----
RedirectMatch permanent ^/foo/?$
http://some.external.site/?var1=val1&var2=val2&var3=val3
----

This didn't quite work as expected since if I enter
http://first.site/foo/, what I see in the URL bar in the browser after
the redirect is:

http://some.external.site/?var1=val1/foo/var2=val2/foo/var3=val3

So, the & has extended to the "left" part of the regex... Maybe this
bug was only with mod_alias's RedirectMatch, so I tried mod_rewrite
instead, in the following way:

----
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/foo/?$
RewriteRule ^/foo/?$
http://some.external.site/?var1=val1&var2=val2&var3=val3 [R,QSA]
----

Same thing! Out of despair, I even tried to combine mod_setenvif with
mod_rewrite:

----
SetEnvIf Request_URI ^ qs=var1=val1&var2=val2&var3=val3
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/foo/?$
RewriteRule ^/foo/?$ http://some.external.site/?%{ENV:qs} [R,QSA]
----

But to my suprise, the ill-fated & striked again! The & in the
environment variable is replaced with whatever was matched by the
regex after Request_URI (even nothing, like in the above example) :(

Is this expected or is this a bug? I have tried and googled for hours
without being able to solve this problem... Is there a simple way to
just make the & literal in right parts? I have tried to backslash it
away to no effect...

Thanks in advance,
-- 

Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris

---------------------------------------------------------------------
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


Mime
View raw message