我的要求是直接的。我有Http://abc需要让它成为Https://abc。我已经在web.config中添加了以下代码。即在IIS中添加了新规则。我已经使用了IIS中的URL重写模块。
<rewrite>
<rules>
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^off$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
</rule>
</rules>
</rewrite>但这对我还是不起作用。帮帮我。
发布于 2017-08-29 21:25:37
你使用的代码非常类似于我在生产中使用的代码,除了我使用redirectType="Permanent",我碰巧使用硬编码的域名来确保一个规范的域,我使用{R:1}作为路径和查询,但我认为使用{HTTP_HOST}{REQUEST_URI}应该可以,但是你可能需要在两者之间加一个斜杠。
试一试:
<system.webServer>
<rewrite>
<rules>
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^off$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>https://stackoverflow.com/questions/45936787
复制相似问题