【发布时间】:2021-09-16 15:00:12
【问题描述】:
该应用程序基于 asp.net core 3.1 构建并做出反应。它们同源。
在 web.config 中从 http 重定向到 https working。
在 web.config 中从 www.example.com 重定向到 example.com 不起作用
// Piece of my web.config
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="RedirectWwwToNonWww" stopProcessing="false">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
- 在浏览器中www.example.com 进入重定向循环并显示
ERR_TOO_MANY_REDIRECTS - 在 Postman 中,错误为
Error: Exceeded maxRedirects. Probably stuck in a redirect loop https://www.example.com/
【问题讨论】:
标签: asp.net asp.net-core iis asp.net-web-api web-config