Skip to content

Instantly share code, notes, and snippets.

@Fogh
Last active April 11, 2018 19:43
Show Gist options
  • Save Fogh/d264ac614253f4f86e9bd6fa36656c64 to your computer and use it in GitHub Desktop.
Save Fogh/d264ac614253f4f86e9bd6fa36656c64 to your computer and use it in GitHub Desktop.
Redirect HTTP to HTTPS, but allow .well-known for refreshing Lets Encrypt certificate
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Allow LetsEncrypt" patternSyntax="Wildcard" stopProcessing="true">
<match url=".well-known/*" />
<action type="None" />
</rule>
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment