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:
- URL ReWrite tool, download address: https://www.iis.net/downloads/microsoft/url-rewrite
But, version 2.1 there is a bug, they hang out before I was a Xiang. So there are times when you might need version 2.0.
2.0 where to download it. From the Web Platform Installer to install it inside.
Operating procedures
Configuration URL into global and non-global graph below can be seen the content URL rewriting component.
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
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
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 localhost
not redirected to the SSL |
This is the online copy and paste a bunch of places do not write clearly.
Operation Redirect
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.
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