Forcing http to https in web.config

My question is how to go about forcing http to https, so every time someone goes on the site it’s always secure

I had placed this is my web.config file:

   <system.webServer>
    <rewrite>
        <rules>
          <rule name="HTTP to HTTPS redirect" stopProcessing="true">
            <match url="(.*)" />
              <conditions>
                <add input="{HTTPS}" pattern="off" ignoreCase="true" />
              </conditions>
            <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
          </rule>
        </rules>
    </rewrite>
  </system.webServer>

I keep getting server errors when I added it. I also tried to 301 redirect from the IIS Manager in URL Rewrite. I’m not necessarily sure if doing this right. If someone can point me in the right direction, I’d super appreciated it!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.