A quick rule to use with IIS UrlRewrite to redirect all HTTP requests to their HTTPS equivalent.
1 2 3 4 5 6 7 8 | <rule name="HTTP to HTTPS" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <conditions> <add input="{HTTPS}" pattern="off" /> <condition scope="serverVariable" index="SERVER_NAME" test="matchRegex" value="localhost|127\.0\.0\.1|::1" negate="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Temporary" /> </rule> |
This rule only does a straight redirect i.e. http://mydomain.com to https://mydomain.com
Update 28 Nov 2017
Rule updated to fix some occasional issues experienced with live sites. The revised rule has been used successfully with a number of sites for a couple of weeks now.
0 Comments
1 Pingback