http到IIS中的https

问题描述 投票:1回答:1

我意识到这是一个简单的问题,但我只是没有找到答案。我已经应用了以下规则......

<rewrite>
          <rules>
            <rule name="HTTP to HTTPS redirect" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                <add input="{HTTPS}" pattern="off" ignoreCase="true" />
              </conditions>
              <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
            </rule>
          </rules>
        </rewrite>

我感兴趣的网址有这个模式

http://[domain]/[directory]/[aspx page]

所以http://example.com/funstuff/thefair.aspx

重写的结果是http://[domain]/[an_aspx_page]

所以重写是删除目录。

我假设{R:1}指定了一个将被重写的参数,我尝试了https:// {HTTP_HOST} / {R:1} / {R:2},但这导致500错误。

我想将此域上的所有流量都指向https,而不更改用户输入的其余网址。

asp.net iis webforms web-config webserver
1个回答
2
投票

以下是我们在其中一个网站上使用的自动将所有流量重定向到https版本的内容。它还包括网址中的其他所有内容。

<rewrite>
      <rules>
          <clear />
          <rule name="Redirect to https" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                  <add input="{HTTPS}" pattern="off" ignoreCase="true" />
              </conditions>
              <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="true" />
          </rule>
      </rules>
  </rewrite>
© www.soinside.com 2019 - 2024. All rights reserved.