IIS URL将HTTP重写为带有端口的HTTPS

我的网站有两个绑定:1000和1443 (端口80/443由另一个网站在同一个IIS实例中使用)端口1000是HTTP端口1443是HTTPS 。 我想要做的是使用“htt p:// server:1000”redirect任何传入的请求到"https://server:1443" 。 我正在玩IIS 7重写模块2.0,但我正在撞墙。 任何见解都被赞赏!

顺便说一句,下面的重写configuration适用于在端口80上具有HTTP绑定和在端口443上具有HTTPS绑定的站点,但它不适用于我的端口。

PS我的url故意有空格,因为“垃圾邮件防范机制”踢了进来。由于某种原因谷歌login不再工作了,所以我不得不创build一个OpenID帐户(没有脚本可能是罪魁祸首)。 我不知道如何让XML很好的显示,所以我在开头的括号后面加了空格。

 < ?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> 

  <rule name="HTTP to HTTPS on different SSL Port" enabled="true" stopProcessing="true"> <match url="(.*)" ignoreCase="true" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="true"> <add input="{HTTPS}" pattern="off" /> <add input="{HTTP_HOST}" pattern="([^/:]*?):[^/]*?" /> </conditions> <action type="Redirect" url="https://{C:1}:1443/{R:0}" appendQueryString="false" /> </rule> 

这解决了我的问题。

即使这个问题是前一个答案,这是我使用的规则。

 <rule name="Redirect to HTTP on different port" enabled="true" stopProcessing="true"> <match url="(.*)"/> <conditions> <add input="{HTTPS}" pattern="ON"/> </conditions> <!-- Cannot Use {HTTP_HOST} as it contains both the {SERVER_NAME}{SERVER_PORT} --> <action type="Redirect" url="http://{SERVER_NAME}:1000{HTTP_URL}" redirectType="Found" appendQueryString="false"/> </rule> 

尝试改变这一点:

 <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}"/> 

对此:

 <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}:1443/{R:1}"/>