【问题标题】:Redirect www to non www https in IIS in elastic beanstalk在弹性beantalk中将www重定向到IIS中的非www https
【发布时间】:2018-01-12 11:22:06
【问题描述】:

我有以下重定向规则,它将所有 http 请求重定向到 https。

 <rule name="Force Https" stopProcessing="true">
      <match url="healthcheck.html" negate="true" />
      <conditions>
        <add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" negate="true" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
    </rule>

我希望这条规则也将所有www 流量重定向到non www https。 应用程序部署到负载平衡的 EBS 环境中。

如果需要任何其他信息,请告诉我。感谢您的宝贵时间。

【问题讨论】:

    标签: .net redirect iis web-config amazon-elastic-beanstalk


    【解决方案1】:

    我在web.config 文件中添加了另一个规则。下面是代码

    <rule name="Remove www" stopProcessing="true">
          <match url="^(.*)$" ignoreCase="false" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
          </conditions>
          <action type="Redirect" url="https://{C:1}/{R:1}" redirectType="Permanent" />
        </rule>
    
        <rule name="Force Https" stopProcessing="true">
          <match url="healthcheck.html" negate="true" />
          <conditions>
            <add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" negate="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
        </rule>
    

    【讨论】:

      猜你喜欢
      • 2019-12-13
      • 2021-12-03
      • 1970-01-01
      • 2019-06-12
      • 1970-01-01
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多