【发布时间】:2021-10-15 12:07:03
【问题描述】:
对于多租户应用程序,我想通过 URL 重写 功能将带有 www 的 URL 重定向到非 www URL。
我在 web.config 文件中添加了几个规则,如下所示。
<rule name="Redirect to non www main domain" stopProcessing="true">
<match url="(.*)" />
<conditions trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="www.test.com" />
</conditions>
<action type="Redirect" url="https://test.com/{R:1}" />
</rule>
<rule name="Force non-WWW" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}/{R:1}" appendQueryString="true" />
</rule>
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
</rule>
这些规则涵盖了所有场景,除了子域的一种场景。
http://subdomain.tezt1.com ==> https://subdomain.tezt1.com (OK)
http://www.subdomain.tezt1.com ==> https://subdomain.tezt1.com (OK)
www.subdomain.tezt1.com ==> https://subdomain.tezt1.com (OK)
@987654327 @ ==> https://subdomain.tezt1.com (OK)
https://www.subdomain.tezt1.com ==> (NOT OK) [期望 - https://subdomain.tezt1.com]
这可能是什么问题?
【问题讨论】:
标签: asp.net-mvc iis url-rewriting iis-7 iis-7.5