Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of ^ON$ and ^OFF$ in url rewrite pattern and what matches this pattern

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?

like image 422
Ashkan Mobayen Khiabani Avatar asked Dec 03 '25 17:12

Ashkan Mobayen Khiabani


2 Answers

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

like image 146
SteveFerg Avatar answered Dec 06 '25 15:12

SteveFerg


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.

like image 39
Akashdeep Srivastava Avatar answered Dec 06 '25 17:12

Akashdeep Srivastava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!