automatically make your web.config file force from HTTP to HTTPS for SSL Security

I know this answer is out there in some form or fashion but I like to have it here for quicker access. This is the section of code that I use to force all of my websites to roll over to SSL in my web.config file.

<system.webServer>
	<rewrite>
		<rules>
			<clear />
			<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}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.