Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerson/c4d8d92d54e723c5600da6a6cfb4fb39 to your computer and use it in GitHub Desktop.
Save cemerson/c4d8d92d54e723c5600da6a6cfb4fb39 to your computer and use it in GitHub Desktop.
HTTP to HTTPS redirect for web.config (ASP.NET)
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="^http$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}{URL}" redirectType="Found" />
</rule>
</rules>
</rewrite>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains; preload" />
</customHeaders>
</httpProtocol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment