我有以下重写规则,它在运行在asp.net上的常规IIS7项目上运行得非常好。
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
因此,在http://{domain}/aboutus
访问时,我们的一个页面将重定向到https://{domain}/aboutus
.现在,在Umbraco站点中放置相同的重写规则会导致无限循环。我们没有任何其他重写规则为我们的Umbraco网站。这导致我认为Umbraco在某种程度上劫持了从http到https的路由,并导致无限循环。我们少了什么?
发布于 2014-12-29 10:11:19
我建议使用以下规则:
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}"
redirectType="Permanent" appendQueryString="false" />
</rule>
发布于 2014-12-29 10:17:27
由于url的regex不是过滤器输入(<match url="(.*)" />
),所以应该在代码中使用redirectType="Permanent"
参数:
更多信息可以在这里找到:
添加Url重写规则
值得注意的是,默认情况下,重定向是302重定向,如果您想重定向301重定向,则需要添加以下内容:
redirectMode="Permanent"
您可以在他们的网站:https://github.com/aspnetde/UrlRewritingNet上找到网址重写组件的完整说明。
发布于 2014-12-30 09:09:21
一个潜在的解决方案是使用Umbraco重写模块而不是IIS重写。
在URL重写配置文件(Config/UrlRewriting.config
)中,以下规则是如何从HTTPS重定向到HTTPS的简单示例:
<add name="https Rewrite"
redirect="Domain"
redirectMode="Permanent"
virtualUrl="http://(.*)"
destinationUrl="https://$1"
ignoreCase="true" />
这个规则应该放在<rewrites>
部分中。
编辑:根据sebastiaan的评论,urlRewriting.net模块已经过时,应该尽可能使用urlRewriting.net解决方案。
https://stackoverflow.com/questions/27612637
复制相似问题