IIS URL Rewrite HTTP to HTTPS with Port

Posted by Andy Arismendi on Server Fault See other posts from Server Fault or by Andy Arismendi
Published on 2011-01-19T03:07:11Z Indexed on 2011/12/01 2:00 UTC
Read the original article Hit count: 595

Filed under:
|
|
|
|

My website has two bindings: 1000 and 1443 (port 80/443 are in use by another website on the same IIS instance). Port 1000 is HTTP, port 1443 is HTTPS. What I want to do is redirect any incoming request using "htt p://server:1000" to "htt ps://server:1443". I'm playing around with IIS 7 rewrite module 2.0 but I'm banging my head against the wall. Any insight is appreciated!

BTW the rewrite configuration below works great with a site that has an HTTP binding on port 80 and HTTPS binding on port 443, but it doesn't work with my ports.

P.S. My URLs intentionally have spaces because the 'spam prevention mechanism' kicked in. For some reason google login doesn't work anymore so I had to create an OpenID account (No Script could be the culprit). I'm not sure how to get XML to display nicely so I added spaces after the opening brackets.

< ?xml version="1.0" encoding="utf-8"?> < configuration> < system.webServer> < rewrite> < rules> < rule name="HTTP to HTTPS redirect" stopProcessing="true"> < match url="(.*)" /> < conditions trackAllCaptures="true"> < add input="{HTTPS}" pattern="off" /> < /conditions> < action type="Redirect" redirectType="Found" url="htt ps: // {HTTP_HOST}/{R:1}" /> < /rule> < /rules> < /rewrite> < /system.webServer> < /configuration>

© Server Fault or respective owner

Related posts about iis7

Related posts about redirect