0

I would like to create redirects to force https and for removal of www so all permutations direct to https://mysite.co.uk

This is a multi site Kentico system so I only want to redirect the specific domain in question.

Here's what I'm currently using but it's not working. Any help greatfuly appreciated.

<rewrite>
  <rules>
    <rule name="mysite https redirect">
      <match url="^(mysite\.co.uk|www\.mysite\.co.uk)$" />
        <conditions>
          <add input="{HTTPS}" pattern="^OFF$" />
        </conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>
Mr Jon
  • 1

2 Answers2

1

You can do this outside of IIS and leave it configured with the site only. If you look in Settings>URLS & SEO (after you select the site you want this configured for, upper left), you can make these changes there without a need to use IIS.

One thing to be sure of is to have your site's domain set as the primary domain you want to use. In your case, mysite.co.uk. Then in the site's domain aliases, add the entry www.mysite.co.uk.

Next, on the root of the site in the Pages app, go to Properties>Security and towards the bottom, select Requires SSL. This will replicate through all pages in the site.

Brenden Kehren
  • 5,919
  • 16
  • 27
  • One issue I have seen with doing it thru Kentico is if you are using AD Authentication for the site. AD Authentication works best on https (won't prompt you to login), but tries to authenticate before Kentico redirects to https, so it will prompt you to login first. If you aren't using AD authentication, everything should work fine. – Zach Perry Sep 04 '18 at 16:12
0

I think you need 2 separate rules. Check this answer here:

<rule name="Remove WWW" enabled="true" stopProcessing="true">
   <match url="(.*)" />
   <conditions>
      <add input="{HTTP_HOST}" pattern="^(www\.)(ccsportal\.com)" />
   </conditions>
   <action type="Redirect" url="https://{C:2}/{R:1}" redirectType="Permanent" />
</rule>


<rule name="HTTP to HTTPS redirect" stopProcessing="true">
   <match url="(.*)" />
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
   </conditions>
   <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent"/>
</rule>
Zach Perry
  • 746
  • 3
  • 12