【发布时间】:2013-03-23 07:32:35
【问题描述】:
我最近为我的网站获得了 SSL 证书,并希望将所有流量重定向到 HTTPS。我把所有东西都转到https://mydomain.com,但如果有人输入http://mydomain.com/anotherpage,它会丢弃另一个页面,只是将用户带到主页。
我在web.config 文件中的规则如下所示:
<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>
我也试过https://{HTTP_HOST}{REQUEST_URI},但没有成功。谁能告诉我我需要做什么才能使网站重定向到页面的正确 HTTPS 版本?我感觉它与模式有关,但我似乎无法弄清楚语法。
【问题讨论】:
-
我认为这与反向引用有关。如果您将模式更改为
url=".*"并重写为url="https://{HTTP_HOST}/{R:0}"怎么办? -
这仍然会将所有内容重定向回主页。
-
这真的很奇怪。您将不得不使用the failed request tracing 工具来查看问题出在哪里。
标签: http iis redirect ssl https