通过IIS将http重定向到https [英] Redirect http to https via IIS
问题描述
我有这个应用程序,我刚刚安装了 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.
- 创建入站规则(空白规则)
- 请求的网址:
匹配模式
- 使用:
通配符
- 模式:
*
- Create inbound rule (Blank Rule)
- Requested URL :
Matches the pattern
- Using:
Wildcards
- 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...
- 右键单击新规则
- 条件 - >添加+
- 条件输入:
{QUERY_STRING}
-
匹配模式
- 模式:
关闭
- Right click your new rule
- Conditions -> Add+
- Condition Input :
{QUERY_STRING}
Matches the Pattern
- 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屋!