Angular 2-始终重定向到https://而不是使用http:// [英] Angular 2 - always redirect to https:// instead of using http://
本文介绍了Angular 2-始终重定向到https://而不是使用http://的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Angular 2应用,我只想在https上运行. 重定向使用http代替https的地址的最佳方法是什么?
I have an Angular 2 app that I only want to run on https. What is the best way to redirect addresses that use http to use https instead?
推荐答案
我向Angular2网站添加了一个web.config,其中包含以下内容.请记住,这是针对IIS托管的应用程序的. 现在,所有地址都重定向到https版本.
I have added a web.config to the Angular2 site which contains the below. Remember that this is for an IIS hosted application. All addresses are now redirected the https version.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
这篇关于Angular 2-始终重定向到https://而不是使用http://的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文