簡體   English   中英

使用 URL 重寫模塊的目標子域和主機域

[英]Target subdomain and host domain with URL rewrite module

下面我有一條規則適用於 example.com 的子域,但我現在需要使用https://example.com (example.com)。 {C:1} 始終是子域,但現在我沒有子域,它需要是“其他”。 如果 {C:1} 是 null 或空為“其他”並匹配沒有子域的主機名,有沒有辦法設置默認值。

<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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM