Articles > Development
Printer Friendly Version
Views: 2118

IIS URL rewrite module HTTP to HTTPS, exclude localhost

Last Updated: 5/6/22

Problem: You want to redirect HTTP requests from users to HTTP, but your sites code makes references to app folders referring to local host using HTTP.  If you unbind HTTP from IIS the HTTP version of the site breaks.

Solution overview: Use the IIS URL rewrite module, but exclude localhost from the rewrite rule.

 

Note on downloading rewrite module:

 

Solution - Part 1:

Follow these steps for URL rewrite for HTTP to HTTPS:

https://www.ssl.com/how-to/redirect-http-to-https-with-windows-iis-10/

 

Solution - Part 2:

Next add an inbould rewrite rule conditions to the HTTP to HTTPS rule. use a new condition for {REMOTE_ADDR}. Set the check type to "pattern does not match" and set the pattern to "127\.0\.0\.1"

Next add another inbould rewrite rule conditions to the HTTP to HTTPS rule. use a new condition for {REMOTE_ADDR}. Set the check type to "pattern does not match" and set the pattern to "::1"

 





Keywords: none