简体   繁体   中英

HTTPS://non-www to HTTPS://www IIS rewrite rule

Looking for IIS rewrite rule for HTTPS://example.co.uk to HTTPS://www.example.co.uk I have been able to redirect HTTP://example.co.uk & HTTP://www.example.co.uk to HTTPS://www.example.co.uk but unable to create a rule to redirect HTTPS://example.co.uk to HTTPS://www.example.co.uk In IIS the site bindings i have are: http www.example.co.uk 80 http example.co.uk 80 https www.example.co.uk 443

    <rule name="https" patternSyntax="Wildcard" stopProcessing="true">
        <match url="*" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{REQUEST_URI}" pattern="https://example.co.uk/*" />
            </conditions>
        <action type="Redirect" url="https://www.{C:0}/{R:1}" />
    </rule>

Not very experienced in creating rewrite rules they are already populated from past colleagues Any assistance would be good: )

you could try below rule:

 <rule name="RedirectNonWwwToWww" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
                        <add input="{HTTPS}" pattern="on" />
                        <add input="{HTTP_HOST}" pattern="^example.co.uk$" />
  </conditions>
  <action type="Redirect" url="https://www.{C:0}/{R:0}" redirectType="Permanent" />
</rule>

Cheers for your help Lex & Jalpa. I ended up creating site with https www site and adding redirect to the https domain.com site it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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