1
我想写下面的网址在C#中重写XMl,但我很努力想知道什么去了哪里。这里是exisitng工作XML:ASP.Net核心:C#中的URL重写中间件#
<rewrite>
<rules>
<!-- BEGIN RULE TAG FOR HTTPS REDIRECT -->
<rule name="Force HTTPS and non-WWW only" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="^www\." ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://mycustomdomain.com/{R:1}" />
</rule>
<!-- END RULE TAG FOR HTTPS REDIRECT -->
</rules>
</rewrite>
我已经在C#到目前为止已经试过:
var options = new RewriteOptions()
.AddRedirect("^(.*)$", "https://mycustomdomain.com/$1")
.AddRedirect(@"^www\.", "https://mycustomdomain.com/$1")
.AddRedirectToHttps(301);
app.UseRewriter(options);
我敢肯定重定向到HTTPS的工作是正确的,但我不知道的重定向中的语法以及非www。
[更新] 所以,我想上面的代码,但我得到:
::ERR_TOO_MANY_REDIRECTS
什么?任何人?
谢谢!