5

I want to serve a PWA using Static websites in Azure Storage and Azure CDN. I need to redirect every HTTP request to HTTPS. I followed the official documentation and waited more than 4 hours but it's not working. Do I need a custom domain for the rule to work?

When SCHEMA = HTTP URL Redirect (301) Source: (.*) Destination: https://%{host}/$1

2 Answers2

1

So I had the same issue. Tried and failed at a few approaches based on a few other stack answers and articles I had stumbled on. This is the XML for the rewrite/redirect rules that ended up working for me:

<rules schema-version="2" rulesetversion="10" rulesetid="960471" xmlns="http://www.whitecdn.com/schemas/rules/2.0/rulesSchema.xsd">
  <rule id="1871708" platform="http-large" status="active" version="5" custid="AA123">

    <description>Redirect HTTP to HTTPs</description>
    <!--If-->
    <match.request-scheme value="http">
      <feature.url-redirect code="301" pattern="/80AA3CF/myblog/(.*)" value="https://blog.mydomain.com/" />
    </match.request-scheme>
  </rule>
  <rule id="1871579" platform="http-large" status="active" version="0" custid="AA123">
    <description>Rewrite to index.html</description>
    <!--If-->
    <match.always>
      <feature.url-user-rewrite pattern="/80AA123/myblog/((?:[^\?]*/)?)($|\?.*)" value="/80AA123/myblog/$1index.html$2" />
      <feature.url-user-rewrite pattern="/80AA123/myblog/((?:[^\?]*/)?[^\?/.]+)($|\?.*)" value="/80AA123/myblog/$1/index.html$2" />
    </match.always>
  </rule>
</rules>

Note that the Rewrite had to appear after the Redirect, and that the Redirect is to a static path - in this case my root domain that the cdn is caching.

dperish
  • 1,493
  • 16
  • 27
1

In the end. I had to talk with Microsoft and they unlock the config.