使用IIS重写多租户应用程序的URL



对于一个多租户应用程序,我想用www重定向URL到非wwwURL从重写特性。
我给网页添加了一些规则。

<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)
https://subdomain.tezt1.com ==>https://subdomain.tezt1.com (OK)
https://www.subdomain.tezt1.com ==>(不可以)[期望- https://subdomain.tezt1.com]

这可能是什么问题?

如果你想删除www,你可以试试这个规则:

<rule name="Remove WWW" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www.(.*)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>

最新更新