我有一个 Angular 2 应用程序,我只想在 https 上运行。 将使用 http 的地址重定向为使用 https 的最佳方法是什么?
最佳答案
我已将 web.config 添加到 Angular2 站点,其中包含以下内容。请记住,这是针对 IIS 托管应用程序的。 所有地址现在都重定向到 https 版本。
<?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 ://instead of using http://,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38334894/