尾随斜杠Umbraco和HTTPs

时间:2015-08-19 13:36:03

标签: asp.net iis url-rewriting umbraco

我有一个位于Netscaler后面的Umbraco网站。所有请求都从http转换为https(通过Netscaler),并使用IIS重写追加尾部斜杠。 IIS重写规则导致HTTPS请求(没有尾部斜杠)插入状态为302的其他请求。基本上:

https://example.com/news(状态301)

http://example.com/news/(状态302)

https://example.com/news/(状态200)

理想情况下,我想要一个301 Redirect,然后一个200 - 我需要删除临时重定向

用于添加尾部斜杠的IIS重写规则:

<rule name="Add trailing slash" stopProcessing="true">
      <match url="(.*[^/])$" ignoreCase="true" />
      <conditions>
        <add input="{REQUEST_METHOD}" pattern="POST" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_URI}" pattern="^/umbraco/" negate="true" />
        <add input="{URL}" pattern="^.*\.(asp|aspx|axd|asmx|css|htc|js|jpg|jpeg|png|gif|mp3|ico|pdf|txt|htm|html|php|xml)$" negate="true" ignoreCase="true" />
        <add input="{URL}" pattern="/Base" negate="true" />
        <add input="{URL}" pattern="cdv=1" negate="true" />
      </conditions>
      <action type="Redirect" redirectType="Permanent" url="{R:1}/" />
    </rule>

我已经在umbracoSettings.config文件中实现了

{addTrailingSlash}true{/addTrailingSlash}

我也尝试过重写规则

 <rule name="HTTP Redirect to HTTPS" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTPS}" pattern="^OFF$" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
        </rule>

但是这导致301的无限循环并且页面死亡

没有想法

1 个答案:

答案 0 :(得分:0)

对它进行排序。

<action type="Redirect" redirectType="Permanent" url="{R:1}/" />

即使重定向是永久性的,也不够,协议是标准端口80.操作类型需要更新为:

<action type="Redirect" url="https://{HTTP_HOST}/{R:1}/" redirectType="Permanent" />

您需要在主机上指定https,在url属性中指定{R:1} /