I have a website stored on azure for which I got an SSL certificate. I am trying to redirect www.mywebsite.com to https://www.mywebsite.com but with no success.
I am using the following code that should change the configuration of IIS where my project is deployed :
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{URL}" pattern="/$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
But when I type my URL it does not redirect to https.
By the way, rewrite appears unrecorgnized by Intellisense.
I can see that you've taken the code snipet from Steve Marx example
The problem is that you have whitespace in your rule name. Just remove them and it will work.
The name attribute of rule must not have spaces; the rule won’t work correctly in IIS on Azure with spaces in the name.
Find the full article here: Azure https guide
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With