IIS7如何实现访问HTTP跳转到HTTPS访问

2019年10月19日10:07:19 评论 1,524
首月免费体验

加几句,1、安装url重写模块,不需要重启IIS,安装完了就能用。个人感觉比 IIS REWRITE组件更好用,iis rewrite是安装第三方的那种,不缴费只可以把所有规则写在一起,不能区别站点,微软自己这个可以区别站点,把规则写在web.config

2、如果你已经安装了并且有规则,直接拷贝下面代码到 <rules></rules>节点中即可。

3、如果已经有其他规则,拷贝下面代码的时候,要放在其他规则前面。不然会有一点小误差。表现为假设你访问 m.xxxx.com/1233 ,它会跳转成了你rewrite之前的地址,比如转为 https://m.xxxx.com/product/?id=1233 。所以得放在所有规则之前,并去掉  stopProcessing="true"

<rule name="redirec to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Temporary" />
</rule>

====

记录一下 以下是指定特定页面不跳转https

<rule name="redirec to https">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/mapp/?$" negate="true" />
<add input="{REQUEST_URI}" pattern="^/mapp/mShop/?" negate="true" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Temporary" />
</rule>

 

 

 

系统:Windows server 2008 R2
软件:IIS7
配置方法:
1.安装URL重写模块(默认是没有安装的)

32位的
http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi
64位
http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi
  • 1
  • 2
  • 3
  • 4

2.服务器打开IIS,点击左侧对应的网站,然后在右面找到”URL重写”项
IIS7如何实现访问HTTP跳转到HTTPS访问
2.添加规则(点击右侧添加规则,选中空白规则,然后确定)
IIS7如何实现访问HTTP跳转到HTTPS访问
3.给规则自定义一个名字(名称自便),模式:(.*)
IIS7如何实现访问HTTP跳转到HTTPS访问
4.添加条件
IIS7如何实现访问HTTP跳转到HTTPS访问
5.配置操作
IIS7如何实现访问HTTP跳转到HTTPS访问
6.点击右上角的应用
注意:
1.ssl设置取消”要求ssl”
IIS7如何实现访问HTTP跳转到HTTPS访问
2.当然你的网站要添加一条网站绑定
IIS7如何实现访问HTTP跳转到HTTPS访问

这样配置就成功了

weinxin
博主微信
这是我的微信扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: