简体   繁体   English

IIS网址重写为多个域的https,但不是全部

[英]IIS url rewrite to https for multiple domains, but not all

i have +10 domains on one solution, and about half of them have had an SSL certificate attached. 我在一个解决方案上有+10个域,其中大约有一半附加了SSL证书。 I seem to have trouble creating ONE rule to make the correct ones being forced onto https. 我似乎在创建一个规则以使正确的规则被强制使用https时遇到麻烦。

I can to a rule for each of them, but feel this should have worked: 我可以为他们每个人做一个规则,但是觉得这应该行得通:

<rule name="HTTP to HTTPS redirect 1" patternSyntax="ECMAScript" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="^www.domainNo1.dk$" />
      <add input="{HTTP_HOST}" pattern="^www.domainNo2.dk$" />
      <add input="{HTTP_HOST}" pattern="^www.domainNo3.dk$" />
      <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>

this leaving the domain4, domain5, etc. alone. 这样就不涉及domain4,domain5等。

Unfortunately it does not kick in when I have more than one domain in the rule. 不幸的是,当我在规则中有多个域时,它不会起作用。 I'm guessing it is the logical grouping that is probably default: 我猜这可能是默认的逻辑分组:

logicalGrouping="MatchAll"

But setting: 但是设置:

logicalGrouping="MatchAny"

will make the sites not work at all. 将使这些站点根本无法工作。 After the redirect to https it continues to redirect the pages, resulting in "ERR_TOO_MANY_REDIRECTS". 重定向到https后,它将继续重定向页面,从而导致“ ERR_TOO_MANY_REDIRECTS”。

I would have thought this was handled by 我本以为这是由

<add input="{HTTPS}" pattern="off" />

But no. 但不是。

Hope anyone can help. 希望任何人都能提供帮助。

You could use below rewrite rule to match multiple domains: 您可以使用以下重写规则来匹配多个域:

<rule name="http to https with multiple domain name" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{HTTP_HOST}" pattern="www.sample1.com|www.sample3.com" />
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
            </rule>

在此处输入图片说明

Regards, 问候,

Jalpa 哈尔帕

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM