httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andy <>
Subject [users@httpd] Re: RewriteCond - Multiple matches
Date Mon, 15 Oct 2012 16:23:48 GMT
Just to post my config and some more detail about the header matching 

RewriteEngine On
RewriteCond %{HTTP:MY-HEADER} (INTERESTING_[a-z0-9_]+).*+ [NC]
RewriteRule .* - [E=THING1:%1]
RewriteRule .* - [E=THING2:%2]
RequestHeader set OUTPUT-HEADER "%{THING1}e,%{THING2}e"

The reason behind the multiple RewriteRules was the fact that I 
couldn't find a way to put a comma into the environment setting part as 
it took that as the delimiter for the flags, escaping and quoting didn't 
appear to help.

So if I put this header in

I only ever get the first match i.e. %1=INTERESTING_1.

If I do this

RewriteCond %{HTTP:MY-HEADER} .*(INTERESTING_[a-z0-9_]+) [NC]
then I get the last one

What I am hoping is that there is a nice way of matching multiple of 
them and reconstructing into a comma separated list, I can cope with 
having to list them out explicitly but am struggling to get a regex 
which allows me to do this.

I would normally in Perl have used the /g modifier however the only 
modifiers I have are NC,L and the slash is taken literally so /g tries 
to match "/g".

Any pointers will be greatly appreciated.



On 2012-10-15 12:16, andy wrote:
> I am having a problem which I believe is related to greedy matching.
> Header on the way in
> MY-HEADER: interesting_1,something_else,interesting_2,interesting_3
> and I want to set an environment variable then use mod_headers to
> replace it with
> MY-HEADER: interesting_1,interesting_2,interesting_3
> Whatever I try I only appear to get the first or last instance
> matched and was expecting to be able to build my output from %1,%2,%3
> in a RewriteRule right after the RewriteCond.
> Any help appreciated.
> Cheers
> Andy.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message