我有一些网站example.org
,我保留子网站example.com/project1
和example.com/project2
等等。我只需要在一些子网站上重定向HTTP→HTTPS
,但不希望手动将其写入代码文件中。IIS URL重写: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部分,任何ARGS。
这是如何解决的?
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
。我做错了什么?