【发布时间】:2016-03-20 22:42:11
【问题描述】:
我有一些网站example.org,在上面我保留了example.com/project1 和example.com/project2 等子网站。我只需要在某些子站点上进行简单的HTTP→HTTPS 重定向,但不想手动将其写入代码文件中。
所以我为他找到了URL-Rewrite2 模块和规则:
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
它最多只能解决一个问题:它从http://example.com/project1 重定向到https://example.com/,因此它丢失了子站点URL 部分和任何参数。
如何解决这个问题?
UPD:使用此规则
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{UNENCODED_URL}" />
</rule>
除了参数重复之外,子站点通常会重定向。 http://example.com/project1?page=2 变成 https://example.com/project1?page=2&page=2。我做错了什么?
【问题讨论】:
标签: iis https url-rewriting url-routing url-rewrite-module