I have a static website hosted on Azure using a storage account with the option 'Static website' enabled. I want users to be able to access the website using the 'https' protocol. So I created a CDN with 'Custom HTTPS' enabled in order to access the content with the https protocol. This works great when accessing the website on the EndPoint Hostname and Origin Hostname. However if I access the website with the http protocol I get the error 'AccountRequiresHttps'. I tried to fix that by using a '.htaccess' file in the root folder to redirect 'http' requests to 'htpps' requests, which does not seem to work.
Content of '.htaccess' file:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Is the '.htaccess' file correct? Or is there a way to enable the http protocol while keeping the https protocol? Or is there another way to redirect http to https?
Azure CDN has a rules engine with which you can redirect a request: https://learn.microsoft.com/nl-nl/azure/cdn/cdn-standard-rules-engine