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