2025年3月25日 星期二 甲辰(龙)年 月廿四 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 服务器 > IIS

IIS7下站点实现从http跳转https

时间:07-23来源:作者:点击数:31

若一个站点同时可通过http和https访问,但需要实现点击http跳转https的效果,该如何实现?

答案是在Web.config添加以下代码实现http跳转到https:

  • <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="Found" url="https://{HTTP_HOST}/{R:1}" />
  •        </rule>
  •      </rules>
  •    </rewrite>
  •  </system.webServer>

注意:若Web.config已有内容,则在配置文件web.config中添加<rewrite>到</rewrite>部分即可

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门