On October 15, 2012 12:23 , andy <andy@xxxxxxxxxxxxxxxxxx> wrote:
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" [...] So if I put this header in INTERESTING_1,something,else,INTERESTING_2,INTRESTING_3 I only ever get the first match i.e. %1=INTERESTING_1.
Correct. %1 matches what is in the first set of parentheses for RewriteCond, %2 matches what is in the second set, and so on. You only have one set of parentheses.
The following will set both %1 and %2, where %1 will begin with "INTERESTING_" and %2 may or may not begin with "INTERESTING_":
RewriteCond %{HTTP:MY-HEADER} (INTERESTING_[a-z0-9_]+),([a-z0-9_]+).*+ [NC]You didn't say what version of Apache HTTP Server you're using, so let's say you're running httpd 2.4.3. In that case, using "RequestHeader edit*" may be a more elegant way to do what you want -- something along the lines of:
RequestHeader edit* MY-HEADER (?=^|,)(?!INTERESTING_)[a-zA-Z0-9_]+(,|$) ""I haven't tested this, and you may need to experiment quite a bit with the regular expression syntax to get things working. What I'm attempting to say here is, edit to request header to remove all instances of things at the beginning of the header's value or following commas which do not begin with the string "INTERESTING_" but consist of a sequence of alphanumeric characters and underscores followed by either a comma or the end of the header.
https://httpd.apache.org/docs/2.4/mod/mod_headers.html#requestheaderNote that the edit* option to RequestHeader is not available in Apache HTTP Server 2.2. See the PCRE documentation for what's legal in regular expressions. Keep in mind that PCRE does not support perl delimiters (that is, enclosing the regular expression in slashes) nor does PCRE support Perl regular expression modifiers such as 'g', 'i', 'm', 's', or 'x'.
Hopefully another member of this mailing list will be able to suggest a more elegant or better tested solution.
-- Mark Montague mark@xxxxxxxxxxx --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx