After configuring SSL for a website, we need to make sure all existing HTTP URLs are automatically redirected to the HTTPS. For this we need to add a redirect rule in our web.config file.
Open your web.config file and add following code snippet under system.webServer tag (copy it before the closing system.webServer tag)
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
Save web.config file and upload it to the server tp replace existing one.