I have the following rule in the `web.config` of my Asp.net MVC website.

When I enable this rule it cause 301 Error loop!

```
<rule name="Redirect to https" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
    <match url="*" negate="false" />
    <conditions logicalGrouping="MatchAny">
            <add input="{HTTPS}" pattern="OFF" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
 </rule>

```

Test the website url `without https` with CURL:

[![enter image description here](https://i.stack.imgur.com/3vHDq.png)](https://i.stack.imgur.com/3vHDq.png)

Notes

* *I get same loop of 302 errors even I try the URL `with https` when the rule is enabled.*
* *I use Cloudflare SSL on my website*

What do you think about this issue? Where is the problem?