IIS configuration Url Rewrite achieve http https redirect method of automatically jump (100% resolved)

introduction

This article can be said that a search online a lot, but why should I write it because I did not put a search for a mad, things are copied East West Norway, and made the poor quality of the entire document. Basically read a few, even Mongolia with a guess just configured.
Of course, I wrote this article in 2020 should be a time, a bit like 49 years into the national army. But rewriting the content or have to write, who told IIS or good use.

Let's say demand scenario

Usage scenarios: First, you have needs, such as our 52ABP enable full SSL encryption station, then the default browser to access the address is: http://www.52abp.com  , I need to http: //www.52abp. com automatically jump to the entrance https://www.52abp.com go, you still have not encrypted path can be accessed.

With demand we then need to prepare for the next tools and environment:

Operating procedures

Configuration URL into global and non-global graph below can be seen the content URL rewriting component.
image.png
Select one site URL rewriting, which we call a separate non-global.
Direct selection of IIS can be configured globally, so there have to rely on your own judgments and choices.

Open Url Rewrite tool

image.png

In the right click 添加, then select 空白规则and configure rules.

Rules command is as follows

This is also a lot of online tutorials God most places, a lot of things are missing, which does not quote the code out. .

Name: Redirect To HTTPS(you can name it ourselves)
mode:  (.*) Then click Ignore case
image.png

Packet processing logic conditions

Referring first logical grouping of information in the figure above.
| Input | Type | mode | whether to ignore case | Note |
|: --- |: -: |: -----: |: -: |: -: |
| {HTTPS} | and mode matching | ^ OFF $ | YES | this is used to match your HTTPS request or the HTTP |
| {} HTTPS_HOST | does not match the pattern | ^ (localhost) | YES | local if you are localhostnot redirected to the SSL |

This is the online copy and paste a bunch of places do not write clearly.

Operation Redirect

image.png

In operational attributes, redirect the URL of: https://{HTTP_HOST}/{R:1} , and then select  附加查询字符串and redirect the type 303 can be.

to sum up

In fact, these are not difficult, but a lot of people writing online information, check writing is not clear nor led to ask a lot of questions.
image.png
final effect

Additional content

The original article in github, if you find mistakes, welcome to participate in collaborative Oh ~]

Collaborative Address: https://github.com/52ABP/Documents/blob/master/src/articles/IISConfigUrlRewrite.md

Published 105 original articles · won praise 17 · views 110 000 +

Guess you like

Origin blog.csdn.net/qq_38890412/article/details/103806603