Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sebastian Dammark 583 posts 1407 karma points
    Jan 09, 2018 @ 13:21
    Sebastian Dammark
    0

    Force everything on a specific domain to run https

    I have a website with 3 languages, and each language have their own domain/subdomain, like this.

    • Danish - domain.dk
    • English - en.domain.dk
    • German - de.domain.dk

    And I have the following rewrite rule in web.config

    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
            <add input="{HTTP_HOST}" pattern="^(domain\.dk)$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
        </rule>
    

    But for some reason http://en.domain.dk and http://de.domain.dk are not redirected to https.

    If I type http://domain.dk/ everything is dandy and switched to https.

    All I want is, to have all subdomains including apex domain, to be forced to https.

  • Cristhian Amaya 52 posts 423 karma points
    Jan 09, 2018 @ 13:40
    Cristhian Amaya
    100

    Hi Sebastian,

    Check the regex on your second input, it says that it must be domain.dk so you are ignoring the sub domains. You can try this one:

    ^(\w{2}\.)?(domain\.dk)$
    

    Cheers, Cristhian.

  • Sebastian Dammark 583 posts 1407 karma points
    Jan 09, 2018 @ 13:41
    Sebastian Dammark
    0

    Thanks a lot :)

  • Sebastian Dammark 583 posts 1407 karma points
    Jan 09, 2018 @ 13:42
    Sebastian Dammark
    0

    This one also solved it for me.

    <rule name="Redirect to https" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
        </rule>
    
  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jan 09, 2018 @ 13:44
    Sebastiaan Janssen
    3

    Make sure to also refer to the documentation about this for Cloud sites, we recommend the rewrite rules as documented so that you can still work locally without having to set up https there.

    https://our.umbraco.org/Documentation/Umbraco-Cloud/Set-Up/#running-your-site-on-https-only

    The ignore for localhost is missing from both the examples above :-)

  • Sebastian Dammark 583 posts 1407 karma points
    Jan 09, 2018 @ 13:48
    Sebastian Dammark
    0

    That's a good point. Thanks.

  • Karl Tynan 16 posts 153 karma points MVP 5x c-trib
    Oct 29, 2018 @ 09:02
    Karl Tynan
    2

    This has now moved to: https://our.umbraco.com/documentation/Umbraco-Cloud/Set-Up/Manage-Hostnames/Rewrites-on-Cloud/ for those looking for the docs in future.

Please Sign in or register to post replies

Write your reply to:

Draft