I use Azure cloud with a web application and my server side written in nodejs . When the web application receives an HTTP request, I want to redirect the request to https. I found a solution. I put this in my web.config file inside the rules tag
<rule name="Force HTTPS" enabled="true"> <match url="(.*)" ignoreCase="false" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="false" redirectType="Permanent" /> </rule>
The problem is that when I type in the browser " https://myURL.com , it redirects everything to the main screen, but when I change https to http" http://myURL.com , it redirects to https: // myURL.com/ "and add the URL" bin / www "according to what the URL looks like this: http://myURL.com/bin/www ", the answer is: the page was not found.
The question is, how do I redirect a clear URL without adding data to the URL?
Part of my web.config file:
<rewrite> <rules> <rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> <match url="^bin/www\/debug[\/]?" /> </rule> <rule name="StaticContent"> <action type="Rewrite" url="public{REQUEST_URI}" /> </rule> <rule name="DynamicContent"> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" /> </conditions> <action type="Rewrite" url="bin/www" /> </rule> <rule name="Force HTTPS" enabled="true"> <match url="(.*)" ignoreCase="false" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="false" redirectType="Permanent" /> </rule> </rules> </rewrite> <security> <requestFiltering> <hiddenSegments> <remove segment="bin" /> </hiddenSegments> </requestFiltering> </security>
Thanks for the answers, Michael.
source share