Pin HTTPS to Azure and add url

I am trying to force HTTP-HTTPS on an Azure website to use the web.config URL rewrite rule. I need a rule that combines both of the following scenarios:

Http://site.domain.com/sitefolder for https://site.domain.com/sitefolder

HTTP://site.domain.com/sitefolder/default.aspx for https://site.domain.com/sitefolder/default.aspx

If I follow this guide , I can force HTTP-HTTPS, but the URL changes to https://site.domain.com without / sitefolder or / sitefolder / default.aspx.

This is what I have at the moment. HTTPS is forced, but the full URL is not included:

<rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="Off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> </rule> 
+5
source share
1 answer

This is a simple rule that does the correct forwarding of HTTPS to Azure WebSites:

  <rule name="Redirect to https"> <match url="(.*)"/> <conditions> <add input="{HTTPS}" pattern="Off"/> <add input="{REQUEST_METHOD}" pattern="^get$|^head$" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/> </rule> 

You can test it here: http://double.azurewebsites.net (note the HTTP in the link) I have no other rules defined here. The rule above redirects to deep links correctly, i.e. http://double.azurewebsites.net/Home/About

+5
source

Source: https://habr.com/ru/post/1203666/


All Articles