So I have a site configured with example.com:80 and www.example.com:80, as well as a certificate for port 443.

When a user goes to the www.example.com:80 or 443, which has the SSL certificate configured correctly (the certificate is specifically for www.example.com, not example.com), everything is fine.

Additionally, if a user browses to domain.com:80, my application is able to redirect to www.example.com:443.

However, if the user types in "https://example.com", they force the load of the site, and the domain doesn't match the certificate. I'm not sure why URL Rewrite doesn't redirect in this case, since I put in "https://example.com" and it shows the correct test result.

Is there some other trick or method to get the redirect to work, or is it "impossible" because you cannot redirect across domains with the HTTPS protocol?

  • Why would you have SSL for www.example.com and not example.com? – Steve Jan 23 '18 at 22:31
  • I've created the certificate using LetsEncrypt for the canonical www.domain.com - this being IIS 7.5, SNI is not an option, so I cannot have multiple certificates. Perhaps the issue is how I'm generating the certificate with LetsEncrypt, but it's my understanding that I cannot create it for both www.domain.com and domain.com. – Jason Beck Jan 24 '18 at 0:40
  • 1
    OK I was able to create a single site multiple binding SAN certificate using LetsEncrypt-Win-Simple for example.com/www.example.com, and my redirect works (because the browser is OK with example.com as long as the certificate is valid.) – Jason Beck Jan 24 '18 at 1:04
  • If this solved your issue, you should answer your own question to help others in future. – Steve Jan 24 '18 at 6:18

Hopefully if you're in a similar bind, this will help.

There are a few techniques for redirection. The URL Rewrite module from iis.net is a good recommendation.

My specific issue was that I had created a single domain SSL certificate for www.example.com, and if you browsed directly to https://example.com, the first thing that happens is detection of a mismatch between certificate and domain name, so redirection couldn't happen. So my fix was just to replace the certificate with a SAN certificate that included both www.example.com and example.com.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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