【问题标题】:IIS RewriteMaps to new URL including WWW and HTTPSIIS RewriteMaps 到新的 URL,包括 WWW 和 HTTPS
【发布时间】:2019-12-13 08:11:20
【问题描述】:

我的 RewriteRules 中有以下规则

<rule name="New URL redirects">
    <match url=".*"/>
    <conditions>
        <add input="{OldUrls:{REQUEST_URI}}" pattern="(.+)"/>
    </conditions>
    <action type="Redirect" url="{C:1}" appendQueryString="false"/>
</rule>

在我的 RewriteMaps 我有以下

<rewriteMap name="OldUrls">
        <add key = "/SomeOldUrl" value = "/New/ShinyUrl" />
</rewriteMap>

我想确保新 url 使用 wwwhttps 作为重定向的一部分,如何将所有这些添加到一个规则中?

【问题讨论】:

    标签: redirect iis


    【解决方案1】:

    你可以试试下面的规则:

     <rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^[^www]" />
                        <add input="{HTTPS}" pattern="off" />
                        <add input="{HTTPS}" pattern="www.sample1.com" negate="true" />
                        <add input="{OldUrls:{REQUEST_URI}}" pattern="(.+)" />
                    </conditions>
                    <action type="Redirect" url="https://www.sample1.com/{C:1}" appendQueryString="true" redirectType="Permanent" />
                </rule>
    

                <rewriteMap name="OldUrls">
                    <add key="/s2" value="/s3" />
                </rewriteMap>
            </rewriteMaps>
    

    【讨论】:

      猜你喜欢
      • 2016-05-08
      • 2018-02-02
      • 2019-04-19
      • 2018-07-05
      • 2021-03-30
      • 1970-01-01
      • 2014-12-16
      • 2015-09-11
      • 2020-11-28
      相关资源
      最近更新 更多