1
我想重定向我的网站从www到非www规则以及http到https(https://example.com)在中间件中。我用来做在web.config的重定向变化,如:ASP.NET核心URL重写
<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>
<rule name="Redirects to www.domain.com" patternSyntax="ECMAScript"
stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />
</rule>
我是新来asp.net的核心,并想知道我怎样才能让我的中间件的重定向?我读了这篇文章:但它并没有帮助我强制我的www重定向到非www。
非常感谢! – Huby03