我将基于SSL身份验证的ASP.NET MVC站点托管为https://example.com 如果用户导航至http://example.com,则应自动重定向至https://example.com 有没有办法做到这一点。
答案 0 :(得分:1)
安装URL Rewrite模块并将以下内容添加到system.webserver
中的web.config中:
<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}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>