【发布时间】:2015-11-12 20:21:09
【问题描述】:
我有一个位于 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 重定向,然后是 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 的无限循环并且页面死掉
没有想法
【问题讨论】:
-
没有回复 - 一定有人遇到过这个问题!!!
标签: asp.net iis url-rewriting umbraco