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"?
https://www.mywebsite.comis 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. – Gisle Hannemyr Jan 10 at 15:44mywebsite.cominto 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 fromhttp(insecure) tohttps(secure). Ifhttps://www.mywebsite.comthrows an certificate error, but nothttps://mywebsite.com, this means that you have a valid ceritificate forhttps://mywebsite.combut not forhttps://www.mywebsite.com. Why is the website set up to use a certificate (with is whathttpsimplies)? – Gisle Hannemyr Jan 10 at 16:04