IIS URL-重写:HTTP到HTTPS

Arm*_*ots 7 iis https url-rewriting url-routing url-rewrite-module

我有一些网站example.org,关于这一点我保留子网站像example.com/project1example.com/project2等.我只需要HTTP?HTTPS对某些子网站进行简单的重定向,但不想手动将其写入代码文件中.

所以我URL-Rewrite2为他找到了模块和规则:

<rewrite>
        <rules>
          <rule name="Redirect to HTTPS" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
              <add input="{HTTPS}" pattern="^OFF$" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
          </rule>
        </rules>
      </rewrite> 
Run Code Online (Sandbox Code Playgroud)

它最多只有一个问题:它重定向http://example.com/project1https://example.com/,所以它丢失了子网站的URL部分和任何args.

如何解决这个问题?

UPD:使用此规则

    <rule name="Redirect to HTTPS" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTPS}" pattern="^OFF$" />
                        </conditions>
                        <action type="Redirect" url="https://{HTTP_HOST}{UNENCODED_URL}" />
</rule>
Run Code Online (Sandbox Code Playgroud)

子网站正常重定向,但参数是重复的.http://example.com/project1?page=2变成了https://example.com/project1?page=2&page=2.我做错了什么?

Arm*_*ots 5

使用此规则完成:

<system.webServer>
  <rewrite>
            <rules>
                <rule name="Redirect to HTTPS" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{UNENCODED_URL}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

适用于子网站.