如何在web.confg中将url重定向到localhost上的ssl url

问题描述

localhost:5011是url,而localhost:44330是SSL url。我想在我的web.config中将http:// localhost:5011重定向到https:// localhost:44330。我为此找到了规则,但是它并没有按照我的意愿工作:

<rule name="Redirect local requests to https" stopProcessing="true">
    <match url="(localhost:5011*)" />
    <conditions logicalGrouping="MatchAny">
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="https://localhost:44330/" redirectType="Permanent" appendQueryString="true" />
</rule>   

这将重定向到https:// localhost:5011。我该如何解决?

解决方法

我认为您的角色不会重定向,因为

如果您需要将http:// localhost:5011重定向到https:// localhost:44330,请尝试使用此规则

 <rule name="Redirect local requests to https" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTPS}" pattern="off" />
                        <add input="{HTTP_HOST}" pattern="localhost" />
                        <add input="{SERVER_PORT}" pattern="^5011$" />
    </conditions>
    <action type="Redirect" url="https://localhost:44330/" redirectType="Permanent" appendQueryString="true" />
</rule>   

II不应将http:// localhost:5011重定向到https:// localhost:5011,因此请检查您是否有其他重写规则,或者您的应用程序是否在执行相同的工作。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...