(Apache)的正则表达式匹配特定的Cookie名称+值(剥离/删除它)? [英] (Apache) Regex to match a specific cookie name+value (to strip/remove it)?
问题描述
我试图用一个RequestHeader编辑指令采取了曲奇标题,并从头部删除特定的Cookie。
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
我想用RequestHeader编辑修改曲奇标头:
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
修改成:
Cookie: header1=123; header2=789
我是可怕的正则表达式用,但我已经能够最接近去是这样的:
I'm horrible with regexes, but the closest I have been able to get to is this:
RequestHeader修改曲奇myheader = *(;)|。myheader = *($)
RequestHeader edit Cookie "myheader=.*(;)|myheader=.*($)" ""
不过,即使是有一个问题,即如果myheadercookie是在曲奇字符串/值是最后一个,我结束了一个分号(;)结尾。
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?
谢谢,
吉姆
P.S。我也想知道:是的饼干与尾随分号有效
P.S. I'm also wondering: Is the Cookie with the trailing semi-colon valid?
推荐答案
尝试:
RequestHeader edit Cookie "(^myheader=[^;]*; |; myheader=[^;]*)" ""
这篇关于(Apache)的正则表达式匹配特定的Cookie名称+值(剥离/删除它)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!