Rewite http to https

Above section system.webServer of web.config we add this code: 
    <rewrite>
        <rules>
            <rule name="RewiteHTTP2HTTPS" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="(HTTPS)" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" logRewrittenUrl="true" />
            </rule>
        </rules>
    </rewrite>