簡體   English   中英

IIS CanonicalHostNameRule用於不同的錯誤子域

[英]IIS CanonicalHostNameRule for different wrong subdomains

我目前有這個CanonicalHostNameRule。
我們有多個頂級域(.ch和.de),這就是為什么我們不使用IIS中默認的CanonicalHostNameRule的原因。

<rule name="RedirectToWWW" enabled="true" stopProcessing="true">
  <match url=".*" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^(?!www)(\S+)\.(de?|ch)$" />
  </conditions>
  <action type="Redirect" url="https://www.{C:0}/{R:0}" />
</rule>

這適用於

http://supertext.ch

但不是

http://holdrio.supertext.ch
http://ww.w.supertext.ch
http://www.mail.supertext.ch

我真的很想將某些子域分別重定向到www.supertext.ch或.de。 有任何想法嗎?

您可以使用以下模式: ^(?!www\\.supertext\\.[de|ch])(\\S+)\\.(de|ch)$

結果將是例如:

holdrio.supertext.ch->

  • {C:0}:holdrio.supertext.ch
  • {C:1}:holdrio.supertext
  • {C:2}:ch

holdrio.supertext.de->

  • {C:0} holdrio.supertext.de
  • {C:1} holdrio.supertext
  • {C:2} de

supertext.ch->

  • {C:0} supertext.ch
  • {C:1}超文本
  • {C:2} ch
<rule name="RedirectToWWW" enabled="true" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(?!www\.supertext\.[de|ch])(\S+)\.(de|ch)$" />
    </conditions>
    <action type="Redirect" url="https://www.supertext.{C:2}/{R:0}" appendQueryString="true" redirectType="Permanent"/>
</rule>

注意:不涵蓋www.supertext.ch.supertext.ch

希望這對您有用。

暫無
暫無

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

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