IIS7:HTTP->HTTPS 干净 [英] IIS7: HTTP->HTTPS Cleanly

查看:23
本文介绍了IIS7:HTTP->HTTPS 干净的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种干净的方法可以将所有访问 HTTP://版本站点的尝试重定向到其 HTTPS://等效项?

Is there a clean way to redirect all attempts to going to an HTTP:// version of a site to its HTTPS:// equivalent?

推荐答案

我认为最干净的方法是描述 在 IIS-aid.com 上.它只是 web.config,因此如果您更改服务器,您不必记住使用 403.4 自定义错误页面或其他特殊权限执行的所有步骤,它就可以正常工作.

I think the cleanest way is as described here on IIS-aid.com. It's web.config only and so if you change server you don't have to remember all the steps you went through with the 403.4 custom error page or other special permissions, it just works.

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
          <match url="(.*)" />
            <conditions>
              <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            </conditions>
            <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

这篇关于IIS7:HTTP-&gt;HTTPS 干净的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆