Hosting Windows Windows Server 

How to redirect HTTP to HTTPS URL in Windows server

Step1: Goto Windows Server and open IIS(internet information service) and select the site to which you want the HTTP URL to be redirected to HTTPS URL.

Step2: Then in Management Section of the Site selected, find “web platform installer” and double click to open, here search for “URL rewrite” keyword after listing that install that to you server IIS.

Note: If, after installing URL rewrite didn’t appear under IIS, please close and reopen the IIS, it will list under IIS tab.

From here you can implement in to ways, Either you use below code or continue with step 4 both works.

Step3: Goto your asp application folder and open web.config file and paste the code provided below before closing tag. If you are following this then there is no need to continue to step 4. if you want to explore more then you can consider.

<rewrite>
            <rules>
                <rule name="HTTPS Redirect" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>

Step4: Then double click URL rewrite and then click on Add rule at the right top, then in that under inbound rules click on the blank rule.

Step5: here give some name to the rule ex:(Http to https) the leave default value as it is. under Match URL in pattern textbox write this pattern ->” (.*) 

Step6: the goto conditions tab below there click on add, in add condition give condition input as ” {HTTPS} “, then, in check if input string, keep default value as it is. then in Pattern write ” ^OFF$ ” and click ok.

Step7: Go to Action tab here in action type dropdown select “Redirect”, then under action properties Rewrite Url enter this pattern :” https://{HTTP_HOST}/{R:1} ” , then in redirect type dropdown select ” see other (303) “.

Step8: in the top right corner now click on Apply to see the changes and go back to IIS site and check your site.

Also Read:  How to configure SQL server to access it remotely

Now for example, if you type http://getcodify.com” then it should go to “https://getcodify.com”.

Related posts