cyborg77
cyborg77

Reputation: 103

URL rewrite IIS 7 replace cookie value for an inbound rule

My re-write rule is

<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>

If the name of the cookie in the inbound request starts with srf_tk_ then replace it with __validation_token the above rule doesn't work. Can someone help me debug this ?

Upvotes: 1

Views: 1876

Answers (1)

cyborg77
cyborg77

Reputation: 103

Figured out what the issue was replace line

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

with

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

Upvotes: 1

Related Questions