Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect website from http to https

Tags:

c#

iis

azure

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.

like image 486
Bryan Arbelo - MaG3Stican Avatar asked Jul 01 '13 16:07

Bryan Arbelo - MaG3Stican


1 Answers

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

like image 192
Fore Avatar answered Oct 22 '22 19:10

Fore