1

I have an IIS7/WinServer2008 configuration with a wildcard SSL certificate installed (*.mydomain.com). The web server holds several websites each configured to route via a host header off the same IP (call it IP1). Some of the sites are configured to use SSL and some are not.

So I have...

a.mydomain.com -> SSL
b.mydomain.com -> non-SSL
c.mydomain.com -> SSL
d.mydomain.com -> non-SSL
e.mydomain.com -> non-SSL

etc...

For the example sites A and C above (the SSL sites) I wanted standard HTTP URL's to redirect to HTTPS. So at the root of IIS (red arrow) I have configured the Error Pages settings by adding a custom Status Code of 403.4 (see below for the settings).

Added customer 403.4 status code

Edit Settings dialog

Edit Feature Settings dialog

The contents of the redirectHttpToHttps.htm file are...

<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://" + httpURL;
    window.location = httpsURL;
}
redirectHttpToHttps();
</script>
<body>
</body>
</html>

Then for both the A and C sites I replaced the old bindings with an SSL binding (routed specifically to IP1) and set the SSL settings to "Require SSL".

So everything works great. Site A redirects http://a.mydomain.com to https://a.mydomain.com and similarly Site C does the same thing.

Now I have a non-wildcard SSL cert to introduce into the mix. This is for the site bound to aaa.customerdomain.com. So I added the cert to my IIS server, and changed the binding of the aaa.customerdomain.com site to use an SSL binding with the new cert and against a new IP2.

So now if I navigate to https://aaa.customerdomain.com, everything works great. However, I don't know how I can get http://aaa.customerdomain.com to redirect to the SSL version.

Can someone help me with the proper way to configure IIS so I can make all this work?

1 Answer 1

1

To handle various types of redirect in IIS try using the url rewrite module

http://www.iis.net/downloads/microsoft/url-rewrite

Then add this in web config per site for http to https redirect:

<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>

You can also accomplish this using GUI via IIS url rewrite module interface: enter image description here enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .