httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis GALIEGUE <>
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 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/?$

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

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/?$ [R,QSA]

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

SetEnvIf Request_URI ^ qs=var1=val1&var2=val2&var3=val3
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/foo/?$
RewriteRule ^/foo/?${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
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
40 avenue Raymond Poincaré
75116 Paris

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message