1

We've got a Sitecore 9 Azure app service instance We've got redirects set up as follows:

<rule name="Root Hit Force HTTPS Redirection" enabled="true" stopProcessing="true">
      <match url="^$" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
        <add input="{HTTP_METHOD}" pattern="GET" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/" redirectType="Permanent" />
</rule>

This seems to be working as expected

Next, what i want

Can anyone please help me with this ?

  • So you want to redirect to https and strip www but only for root url (/)? – Marek Musielak Nov 5 '19 at 21:12
  • Hi Marek , thanks for your reply , apologies for not making it clear , not only root url(/), any url request , if it contains www, I want to strip www and redirect to https – SitecoreNoob Nov 5 '19 at 21:45
0

Below is a rule to remove www from a URL, copied from this blog post. It meets the requirements you've specified:

  • It will handle both http and https (you have https redirect already in place);
  • It applies not only for the root URL(/);
  • It will also work with any hostanme, a hostname is not hardcoded;

Remove www:

<rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="true">
  <match url="*" />
  <conditions>
    <add input="{CACHE_URL}" pattern="*://www.*" />
  </conditions>
  <action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" />
</rule>

This rule handles only the removal of www, so it comes as an addition to the https rule you have, not as a replacement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.