In previous article, we saw how to add an SSL certficate to Azure Web App. Even if you have an SSL certificate, it doesn’t mean that all your users are going to use the same one. For that, you have to redirect users to the HTTPS while they try to access HTTP.
When someone checks out websites with http and https, they get the Web app. Now, what we want is to redirect the users who use http to the https link.



Let us see how to make it possible. Here, I am going to open the project I made in a previous article where I deployed a Web app using Visual Studio.
On Solution Explorer, you can see the Web.config file.
Add the following code snippet to the Web.config file. Open the file to get it done. You just need to add a piece of code to your Web.config file.
- <system.webServer>
- <rewrite>
- <rules>
- <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="true" redirectType="Permanent"/>
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
What we are doing is just rewriting - when somebody comes to http, redirect them to https.
Publish your profile and try to access the Web app using HTTP. Here, you see that it will automatically redirect to HTTPS.

Jefferson S. MottaPosted Aug 15, 2019, 2:17 PM
Hi, but you must have the module rewrite before config: https://hostadvice.com/how-to/how-to-enable-mod_rewrite-on-iis/
Former memberPosted May 16, 2017, 7:42 AM
Url rewrite may make the web site slow because always http will be https.
Nigel FernandesPosted May 14, 2017, 8:24 PM
URL rewrites can sometimes lead to redirect loop, i think its better to redirect with 301 in Application_BeginRequest in global.asax