通过IIS将http重定向到https [英] Redirect http to https via IIS

查看:369
本文介绍了通过IIS将http重定向到https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个应用程序,我刚刚安装了 SSL 证书。是的,我试图将用户重定向到仅使用 HTTPS://url.com 。并阻止他们使用 http://url.com网站。但是因为我不了解正则表达式来定义模式和条件,遗憾的是,我找不到一个如何定义这些规则的示例的指南。我知道有些人会对这个问题进行投票,这没关系,但我认为这将有助于许多其他人能够找到相同的通用教程而不给出如何设置的具体示例 https:/ / {HTTP_HOST} {REQUEST_URI}

I have this application that I just installed a SSL certificate for. Yest I tried to redirect the users to use only the HTTPS://url.com. and prevent them from using the http://url.com site. However because I lack understanding the regular expressions to define the Pattern and the condition and unfortunately, I could not find a guide with some example of how to define those rules. I know some people will down vote the question, it is OK, but I think it will help many other who can find the same generic tutorial with out giving a concrete example of how to set this up https://{HTTP_HOST}{REQUEST_URI}.

推荐答案

确保添加了URL重写功能。在IIS管理器中,在URL重写部分中配置以下内容。

Ensure you have the URL Rewrite feature added. In IIS manager configure the following in the URL rewrite section.


  1. 创建入站规则(空白规则)

  2. 请求的网址:匹配模式

  3. 使用:通配符

  4. 模式: *

  1. Create inbound rule (Blank Rule)
  2. Requested URL : Matches the pattern
  3. Using: Wildcards
  4. Pattern: *

条件


  • 输入: {HTTPS}

  • 类型:匹配模式

  • 模式:关闭

  • Input: {HTTPS}
  • Type: Matches the pattern
  • Pattern: off

行动


  • 行动类型:重定向

  • 重定向网址: https:// {HTTP_HOST} {REQUEST_URI}

  • 追加查询字符串已检查

  • 重定向类型:找到(302)

  • Action Type: Redirect
  • Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
  • Append Query String Checked
  • Redirect type: Found (302)

完成此操作后。创建条件......

Once you have done this. Create a condition...


  1. 右键单击新规则

  2. 条件 - >添加+

  3. 条件输入: {QUERY_STRING}

  4. 匹配模式

  5. 模式:关闭

  1. Right click your new rule
  2. Conditions -> Add+
  3. Condition Input : {QUERY_STRING}
  4. Matches the Pattern
  5. Pattern: off

基本上它应该是这样的:

Essentially it should look like this:

使用http请求的所有流量将自动重定向到https端口。

All traffic using a http request will be automatically redirected to the https port.

这篇关于通过IIS将http重定向到https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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