URL重写IIS 7替换入站规则的cookie值

时间:2012-09-07 10:08:33

标签: iis-7 url-rewrite-module

我的重写规则是

<rewrite>
  <rules>
    <rule name="rewrite cookie - inbound" enabled="true">
      <match url=".*" />
      <conditions trackAllCaptures="true">
        <add input="HTTP_COOKIE" pattern="(.*)__srf_tk_(.*)" />
      </conditions>
      <serverVariables>
        <set name="HTTP_COOKIE" value="{C:1}__validation_token__{C:2}" />
      </serverVariables>
      <action type="None" />
    </rule>
  </rules>
</rewrite>

如果入站请求中的Cookie名称以 srf_tk_开头,则将其替换为__validation_token 上述规则不起作用。有人可以帮我调试吗?

1 个答案:

答案 0 :(得分:1)

找出问题所在 替换行

<add input="HTTP_COOKIE" pattern="(.*)__srf_tk_(.*)" />

<add input="{HTTP_COOKIE}" pattern="(.*)__srf_tk_(.*)" />