Skip to content

Instantly share code, notes, and snippets.

@ainsofs
Last active March 18, 2020 19:12
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 ainsofs/ee2652343d30b5ee5c474b8f78c92ada to your computer and use it in GitHub Desktop.
Save ainsofs/ee2652343d30b5ee5c474b8f78c92ada to your computer and use it in GitHub Desktop.
web.config redirect http to https
<!-- requires url rewrite module --->
<!-- https://docs.microsoft.com/en-us/archive/blogs/dawiese/redirect-from-http-to-https-using-the-iis-url-rewrite-module -->
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect http to https" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
</rule>
</rules>
</rewrite
</system.webServer>
<!-- hiding version numbers -->
<!-- https://www.saotn.org/remove-iis-server-version-http-response-header/ -->
<!-- within system.webServer -->
<rewrite>
<outboundRules rewriteBeforeCache="true">
<rule name="Remove Server header">
<match serverVariable="RESPONSE_Server" pattern=".+" />
<action type="Rewrite" value="" />
</rule>
</outboundRules>
</rewrite>
<!-- within system.webServer -->
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By" />
</customHeaders>
</httpProtocol>
<!-- within system.web -->
<httpRuntime
enableVersionHeader="false" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment