Redirect to HTTPS using Web.config Print

  • programming, redirect, https, web.config
  • 1

Add the source code following in system.webServer section (web.config):

<rewrite>
  <rules>
    <rule name="HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://WWW.YOUR-DOMAIN.COM/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

Was this answer helpful?

« Back