Reputation: 1334
I am trying to use a "RequestHeader edit" directive to take the "Cookie" header, and remove a specific cookie from that header.
In other words, suppose the incoming "Cookie" header was:
Cookie: header1=123; myheader=abc; header2=789
I want to use "RequestHeader edit" to modify that "Cookie" header to:
Cookie: header1=123; header2=789
Or, as another example, if the incoming "Cookie" header was:
Cookie: header1=123; header2=789; myheader=abc
change that to:
Cookie: header1=123; header2=789
I'm horrible with regexes, but the closest I have been able to get to is this:
RequestHeader edit Cookie "myheader=.*(;)|myheader=.*($)" ""
But, even that has a problem, that if the "myheader" cookie is the last one in the "Cookie" string/value, I'm ending up with a semi-colon (";") at the end.
Can anyone provide a regex that would do this completely correctly?
Thanks, Jim
P.S. I'm also wondering: Is the Cookie with the trailing semi-colon valid?
Upvotes: 2
Views: 7806
Reputation: 272096
Try:
RequestHeader edit Cookie "(^myheader=[^;]*; |; myheader=[^;]*)" ""
Upvotes: 9