Copied to clipboard

Flag this post as spam?

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


  • Carsten A Pedersen 5 posts 75 karma points
    Aug 06, 2019 @ 16:20
    Carsten A Pedersen
    0

    Redirect to https

    Hi everyone, I have installed Umbraco version 8.01 on Unoeuro.com. I set up the SSL certificate that is available and in Web.config changed this:

    -- add key="Umbraco.Core.UseHttps" value="false" --

    to this:

    -- add key="Umbraco.Core.UseHttps" value="true" --

    This works fine for backoffice.

    However I would like to enforce https on Front-end as well but everything I tried turns into an error.

    Does anyone have a great way to ensure and enforce http > https in version 8.01?

    //Carsten - Denmark

  • Amir Khan 1251 posts 2660 karma points
    Aug 06, 2019 @ 18:35
    Amir Khan
    2

    You can add this to your webconfig or to a separate config file and reference that file from the web.config, documentation is here: https://our.umbraco.com/documentation/reference/routing/IISRewriteRules/

    <rule name="Force HTTPS" enabled="true" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAny">
        <add input="{HTTPS}" pattern="off" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
    </rule>
    
  • Carsten A Pedersen 5 posts 75 karma points
    Aug 14, 2019 @ 11:32
    Carsten A Pedersen
    0

    Thank you Amir, I will give it a go

    //Carsten

  • Roger Withnell 127 posts 612 karma points
    Apr 21, 2021 @ 10:08
    Roger Withnell
    0

    I have several websites on one instance of Umbraco 7.2.8 on my server. They are all http sites and I'm upgrading them one at a time to https. I am trying to set a rule in the web.config for specific sites. This is my rule but it doesn't seem to work. greywell.info is the domain name that I want to changes from http to https:

       <rewrite>
            <rules>
              <rule name="Force HTTPS" enabled="true" stopProcessing="true">
                <match url="greywell.info" />
                <conditions logicalGrouping="MatchAny">
                  <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
              </rule>              
            </rules>
        </rewrite>
    

    What am I doing wrong? Your help would be much appreciated.

    Thanking you in anticipation.

    Roger

  • Amir Khan 1251 posts 2660 karma points
    Apr 21, 2021 @ 14:21
    Amir Khan
    1

    Something like this should work.

    <rule name="grewell.info https" stopProcessing="true">
        <match url=".*" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^(www.)?greywell.info$" />
        </conditions>
        <action type="Redirect" url="https://grewell.info" appendQueryString="false" redirectType="Permanent" />
    </rule>
    
  • Roger Withnell 127 posts 612 karma points
    Apr 21, 2021 @ 15:49
    Roger Withnell
    0

    Thanks, Amir, but when I apply this rule I get "This page isn’t working, greywell.info redirected you too many times" in both Chrome and Edge

  • Amir Khan 1251 posts 2660 karma points
    Apr 21, 2021 @ 15:56
    Amir Khan
    0

    Hmm, no other redirects in there?

    Maybe try changing conditions to:

    <conditions logicalGrouping="MatchAny">
    
  • Roger Withnell 127 posts 612 karma points
    Apr 21, 2021 @ 16:00
    Roger Withnell
    0

    Changed that but the same problem.

  • Amir Khan 1251 posts 2660 karma points
    Apr 21, 2021 @ 16:03
    Amir Khan
    0

    And you're sure there's no other redirects for that domain somewhere? The reason I ask is I grabbed that straight out of production and just updated the domains based on the info you provided.

  • Roger Withnell 127 posts 612 karma points
    Apr 29, 2021 @ 12:04
    Roger Withnell
    0

    Using Chrome > inspect > Network and reloading the page, there were several https redirects, perhaps from images and documents on the page? I fixed it using the following rule for upperbridge.co.uk, which stops the redirect if the prefix is https://:

    <rule name="upperbridge.co.uk https" stopProcessing="true">
                <match url=".*" />
                <conditions>
                        <add input="{HTTP_HOST}" pattern="^http://(www\.)*upperbridge.co.uk$" />
                </conditions>
                <action type="Redirect" url="https://upperbridge.co.uk" />
              </rule>
    

    If I remove the http bindings from IIS, however, browsers that have not used https go to the IIS default page. I've left the http bindings in IIS so the page opens on http but will open on https if the https:// prefix is added. Searching on "Upper Bridge Enterprises" lists the https:// page.

    Hope this helps.

    Roger

  • Mehmet Avcı 41 posts 133 karma points
    Aug 23, 2021 @ 09:36
    Mehmet Avcı
    0

    Heya,

    It is great that you made it work but I guess there can be a small iteration.

    Now this line matches for anything you see in the address bar.

        <match url=".*" />
    

    After that comes condition, just one in your case.

    <add input="{HTTP_HOST}" pattern="^http://(www\.)*upperbridge.co.uk$" />
    

    As you can see you are matching all with for http_host value. Normally you want these conditions to cover correct parts and if you don't want your rule to be run when it is on https, you should add condition below. It would help you greatly if you have multiple domain names assigned.

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

    You can consider this, without giving and domain names, you can actually redirect all into https, to same domain or each to its own.

    Hope this helps.

    Mehmet

Please Sign in or register to post replies

Write your reply to:

Draft