【问题标题】:http to https in IISIIS 中的 http 到 https
【发布时间】:2016-04-27 22:44:16
【问题描述】:

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

<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,而不更改用户输入的其余 url。

【问题讨论】:

标签: asp.net iis webforms web-config webserver


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2019-09-03
    • 2016-03-20
    • 1970-01-01
    • 2013-05-02
    • 2019-08-17
    • 2013-03-23
    • 2011-09-16
    • 1970-01-01
    • 2019-11-29
    相关资源
    最近更新 更多