【问题标题】:Single Rule for lowercase WWW HTTPs in IIS URL RewriteIIS URL 重写中小写 WWW HTTPs 的单一规则
【发布时间】:2015-08-03 16:06:54
【问题描述】:

我正在尝试创建一个 SINGLE 重写规则(以避免多次 301 重定向),它将所有请求转换为 https、小写、www 前缀。

所以,http://example.com/Page 将是 https://www.example.com/page - 都在一个规则中。

我该怎么做?

【问题讨论】:

    标签: asp.net iis url-rewriting


    【解决方案1】:
    <rule name="All in one URL" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAny">
            <add input="{HTTPS}" pattern="off" />
            <add input="{REQUEST_URI}" pattern="[A-Z]" ignoreCase="false" />
            <add input="{HTTP_HOST}" pattern="^www\." negate="true" />
         </conditions>
         <action type="Redirect" url="https://www.example.com:35077{ToLower:{URL}}" />
    </rule>
    

    这条规则可以做到这一点:

    • 小写网址
    • 强制使用 HTTPS
    • 必要时添加 www

    【讨论】:

      猜你喜欢
      • 2020-11-28
      • 2015-08-12
      • 1970-01-01
      • 2018-02-02
      • 1970-01-01
      • 2016-05-08
      • 1970-01-01
      • 2011-09-18
      • 2011-04-21
      相关资源
      最近更新 更多