0

I hosted my ASP.NET MVC site based on SSL authentication as https://example.com.
If user navigate to http://example.com it should automatically redirect to https://example.com.
Is there any possible way to do this.

Clinton Prakash
  • 967
  • 9
  • 20

1 Answers1

1

Install the URL Rewrite module and add the below to your web.config in system.webserver:

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