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
什麼?任何人?
謝謝!