Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I use mywebsite.com IIS will do as expected and redirect it to https://mywebsite.com.

If I use http://mywebsite.com IIS will do as expected and redirect it to https://mywebsite.com.

But, if I use www.mywebsite.com I get a certificate error.

How do I create a rewrite scripts to redirect www to HTTPS?

share|improve this question
Your question does not make sense. The construct https://www.mywebsite.com is an URL, made up of a scheme (https) and a hostname (www.mywebsite.com). When you write "How do I create a rewrite scripts to redirect 'www' to 'https'", it appears that you try to rewrite the non-canonical portion of the hostname (www) to a scheme. I've no idea why you want to do this, but can assure you that it does not make sense. Try expanding the question to include something about what you try to accomplish, rather than asking for directions for doing things that does not make sense. – Free Radical Jan 10 '13 at 15:44
Thanks for the feedback. I guess I am not sure how to write the question since I am not at all familiar with IIS, so I apologies for my ignorance. Could this be a certificate issue? Like I mentioned above the url works fine when typing "mywebsite.com" or "http"//mywebsite.com" into the browser and will redirect it to "https". However typing "www.mywebsite.com" into the browser redirects to "https" but with a cerficate error. I am just trying to understand this. Thank- you. – user21346 Jan 10 '13 at 15:56
The fact that typing mywebsite.com into the browser "works" is probably caused by two things, the first is that your browser in being nice and filling in the default scheme (http) for you, then IIS rewrites the scheme from http (insecure) to https (secure). If https://www.mywebsite.com throws an certificate error, but not https://mywebsite.com, this means that you have a valid ceritificate for https://mywebsite.com but not for https://www.mywebsite.com. Why is the website set up to use a certificate (with is what https implies)? – Free Radical Jan 10 '13 at 16:04
Got it - thanks again. – user21346 Jan 10 '13 at 16:06
up vote 0 down vote accepted

You should check the common name on the certificate you purchased from your CA. While some CA's will give you a bonus subject alternate name of www.mywebsite.com if you buy a certificate using common name of mywebsite.com (and vice versa), others do not and your cert could just be bound to the common name of mywebsite.com.

Your certificate error doesn't look to be related to your redirect but to the common name bound to the certificate. Any web browser should give you the ability to view additional details on that certificate warning in order to determine why the warning is getting thrown.

share|improve this answer
Thank you. Yes, I just checked and the common name is "mywebsite.com". I did notice that I have two certificates, one for "mywebsite.com" and one for "www.mywebsite.com". This all started when one expired and I had to renew it. I am sure I am the cause of my own problems here! – user21346 Jan 10 '13 at 16:49
Okay, I think I found the problem. It looks like "www.mywebsite.com" is using the "mywebsite.com" certificate, which I believe is throwing the certificate error when going to "www.mywebsite.com". I realize this is all probably "first-grade" stuff to you guys, so I just want to say thank you for your help, comments and patients. – user21346 Jan 10 '13 at 16:58

You can strip the www from the URL using this method as outlined here.

Does your SSL redirect rule look similar to the following?

<rule name="Redirect all to HTTPS" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                    <add input="{SERVER_PORT}" pattern="443" negate="true" />
              <action type="Redirect" url="https://mywebsite.com/{R:0}" />
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.