Skip to content

Instantly share code, notes, and snippets.

@valadas
Created March 27, 2023 20:45
Show Gist options
  • Save valadas/0fb51a966811f846240366adc26c4b6f to your computer and use it in GitHub Desktop.
Save valadas/0fb51a966811f846240366adc26c4b6f to your computer and use it in GitHub Desktop.
Force IIS redirection to https for all urls

Forces all urls to use HTTPS in IIS

web.config

<configuration>
  ...
  ...
  <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="Permanent" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
      </rules>
    </rewrite
  </system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment