Copied to clipboard

Flag this post as spam?

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


  • J 445 posts 862 karma points
    Oct 16, 2017 @ 11:13
    J
    0

    Redirect to https for one site

    I used this article to have two sites in Umbraco and then configure IIS to do two redirects (site1 to www.site1.com and site2 to www.site2.com).

    https://weblogs.asp.net/owscott/iis-url-rewrite-rewriting-non-www-to-www

    This has been working well but then i need to change this to HTTPS but it still shows the http version on some occasions (i realised this after clearing my browser) for example if i enter site1.com then it goes to http://site1.com instead of httpS://www.site1.com.

    How could i achieve this?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Oct 16, 2017 @ 11:56
    Alex Skrypnyk
    0

    Hi J

    Try this configuration for redirects:

    <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
          <match url="(.*)"/>
          <conditions>
            <add input="{HTTP_HOST}" pattern="^site1.com$" negate="true"/>
            <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/>
        </rule>
        <rule name="Redirect to www" stopProcessing="true">
          <match url="(.*)" />
          <conditions trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^site1.com$" />
          </conditions>
          <action type="Redirect"
            url="{MapProtocol:{HTTPS}}://www.site1.com/{R:1}" />
        </rule>
    
    
        <rule name="Redirect to www" stopProcessing="true">
          <match url="(.*)" />
          <conditions trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^site2.com$" />
          </conditions>
          <action type="Redirect"
            url="{MapProtocol:{HTTPS}}://www.site2.com/{R:1}" />
        </rule>        
      </rules>
    
  • J 445 posts 862 karma points
    Oct 16, 2017 @ 13:29
    J
    0

    Im about to try this out but my initial attempt didnt work (I tried modifying my config), so now i will copy it across. Just in case this changes the above but the second site should not be https

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Oct 16, 2017 @ 13:31
    Alex Skrypnyk
    0

    Just edited the config changes, now it shouldn't redirect site2 to https

  • J 445 posts 862 karma points
    Oct 16, 2017 @ 13:54
    J
    0

    I copied/pasted the code above and changed the site name and it doesnt work. It throws an error 500, removing the second rule (redirect to http) stops the error but site 2 doesnt work at all :-(

    Edit: Getting a little further and i have the redirect working to https but when i type site1.com then it goes to http, Going to www.site1.com then redirects to https which is fine.

    Following this i will look into site 2

Please Sign in or register to post replies

Write your reply to:

Draft