使用 URL 重写模块的目标子域和主机域

Target subdomain and host domain with URL rewrite module

下面我有一个规则适用于 example.com 的子域,但我现在需要使用 https://example.com (example.com)。 {C:1} 始终是子域,但现在我没有子域,它需要是 "other"。如果 {C:1} 为 null 或为空 "other" 并匹配没有子域的主机名,是否有办法设置默认值。

<rule name="Apple Icon Rewrite" stopProcessing="true">
          <match url="^(apple-touch-icon.*?)(?:-precomposed)?(.png)$" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^(.*).example.com$" />
          </conditions>
          <action type="Rewrite" url="/assets/sports/{C:1}/icons/{R:1}{R:2}" appendQueryString="false" />
        </rule>

您可以只添加一个额外的规则,它将只捕获 exmple.com 个这样的域:

<rule name="Apple Icon Rewrite" stopProcessing="true">
      <match url="^(apple-touch-icon.*?)(?:-precomposed)?(.png)$" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^example.com$" />
      </conditions>
      <action type="Rewrite" url="/assets/sports/other/icons/{R:1}{R:2}" appendQueryString="false" />
</rule>