19

I came across this rule:

<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
 <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>

what is ON or OFF in pattern and what matches this pattern?

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171

2 Answers2

24

The pattern OFF is make sure that the rule executes only when the request comes in over http or else you might end up in an infinite loop.

So add a condition stating that {HTTPS} is OFF.

the ^ = (start of string, or "negative" if at the start of a range)

the $ = (end of string)

though the extra start/stop characters seem redundant for this purpose

Here is a blog that discusses inbound rules

SteveFerg
  • 3,466
  • 7
  • 19
  • 31
0

input={HTTPS} could provide two input values, either OFF (for NO-HTTPS request) or ON(for an HTTPS request). Hence, to which if the pattern value matches, the rule gets executed. And that is why pattern="OFF" makes sure that the request comes in over http. Accordingly the rule gets executed.