Redirect HTTP to HTTPS

Method1: Using http Redirect feature:

To know more see earliar section.

Method2: Using custom error page:

Step1:

First bind website with https. To binding website see earliar section,s step3.

Step2:

Enable SSL on this website. to do this ->

Go to IIS-Expand server name-sites- select “site name” – in feature view select “SSL setting- select ” require SSL”-Apply.

Step3:

Create a web page Using HTML & Java script codes as given below.

<html>

<head>

<title>Redirecting…</title>

</head>

<script language=”JavaScript”>

function redirectHttpToHttps()

{

var httpURL= window.location.hostname + window.location.pathname +

window.location.search;

var httpsURL= “https://&#8221; + httpURL;

window.location = httpsURL;

}

redirectHttpToHttps();

</script>

<body>

</body>

</html>

save it as “c:\intpub\”HttpRedirect.htm”.

step4:

IIS – sites – site name – (feature view)error pages-add-status code 403.4 & browse HTTP redirect.htm-ok

step5:

IIS-sites-site name-(feature view)error pages-select 403.4- edit feature setting-select custom error page & browse httpredirect.htm & path type file or redirect-OK.

Method 3: Using custom web.config  file:

Step1:

Enable SSL on this website.

step2:

Download Url Rewrite Module and install it.

Step3:

You have to add a script in “c:\intpub\wwwroot\web.config” file  under <configuration> section which is given below.

<rewrite>

<rules>

<rule name=”https redirect”>

url=”(.*)” ignoreCase=”false” />

<conditions>

<add input=”{HTTPS}” pattern=”off” ignoreCase=”false” />

</conditions>

<action type=”Redirect” redirectType=”Found” url=”https://{HTTP_HOST}{REQUEST_URI}”/>

</rule>

</rules>

</rewrite>

save the web.config file.

Step4:

Restart IIS. Test Url Redirection will work fine.

Advertisements

One response to “Redirect HTTP to HTTPS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s