【问题标题】:Force https redirect on all http requests on IIS强制对 IIS 上的所有 http 请求进行 https 重定向
【发布时间】:2015-07-02 13:13:08
【问题描述】:

我想强制所有http请求重定向到https,所以我现在有了这条规则:

  <rules>
      <clear />
      <rule name="force https" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
          <add input="{HTTP}" pattern="on" ignoreCase="true" />
          <add input="{HTTP_HOST}" pattern="(sitea\.com)|(sitea\.uk)|(sitea\.org)" negate="true" ignoreCase="true" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
      </rule>
  </rules>

但是当我请求例如http://www.sitea.com 时,它不会重定向到https://www.sitea.com。 (旁注:我也想知道这是否对 SEO 有任何负面影响)

【问题讨论】:

    标签: asp.net https rewrite iis-7.5


    【解决方案1】:

    这就是我们使用的

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

    我可以看到一些差异 - 我们在 {R:1} 的地方有 {REQUEST_URI} 并且我们只输入了一个关闭 https 的条件,因此只有 http 被重定向,这可能是你出错的地方。

    至于 SEO - 这是一个大主题 - 但由于您正在执行永久重定向,搜索引擎会识别出这一点并将网址从其索引中取出,并使用 https 代替。

    【讨论】:

      猜你喜欢
      • 2014-06-30
      • 2017-04-30
      • 2020-10-31
      • 2015-01-28
      • 1970-01-01
      • 2011-05-04
      • 2016-11-17
      相关资源
      最近更新 更多