web-config url重写了太多重定向问题

时间:2017-04-21 18:16:38

标签: asp.net redirect url-rewriting web-config

当我尝试使用以下规则将所有http请求重定向到https时,会发生“太多重定向”... 当我将第一个规则的启用设置为false时,它可以,但只是表单页面重定向。 非常感谢你的回复。

    <rules>
    <clear />
            <rule name="Redirect to https" enabled="true" stopProcessing="true">
                <match url=".*" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    <add input="{URL}" matchType="Pattern" pattern="\/Admin\/(.+).(aspx)" negate="true" />
                    <add input="{URL}" matchType="Pattern" pattern="\/modules\/(.+).(aspx)" negate="true" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
            </rule>                
            <rule name="CanonicalHostNameRule1">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="^www\.xxxxx\.com$" negate="true" />
                </conditions>
                <action type="Redirect" url="https://www.xxxxx.com/{R:1}" />
            </rule>

            <rule name="km-old-rdr" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                    <add input="{URL}" pattern="\/kategori\/(.+).(aspx)" />
                    <add input="{URL}" pattern="\/kategori\/(.+).(aspx)" />
                    <add input="{URL}" pattern="\/urun\/(.+).(aspx)" />
                </conditions>
                <action type="Redirect" url="{C:1}" />
            </rule>
            <rule name="KM301" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{URL}" pattern="(.+).(axd)" negate="true" />
                    <add input="{DB:{R:0}301}" pattern="(.+)" />
                </conditions>
                <action type="Redirect" url="{C:1}" appendQueryString="false" />
            </rule>
            <rule name="KMRewrite" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{URL}" pattern="(.+).(axd)" negate="true" />
                    <add input="{DB:{R:0}}" pattern="(.+)" />
                </conditions>
                <action type="Rewrite" url="{C:0}" />
            </rule>
  </rules>

0 个答案:

没有答案