简体   繁体   中英

IIS Url Rewrite rule HTTP to HTTPS AND add WWW

I have a website that I want to be only used with the WWW sub-domain and via HTTPS. I had an URL rewrite working for adding WWW. But now I also want to force a HTTP to HTTPS redirect. Just forcing HTTPS works as well, but when I can't really figure out how to combine the 2.

Can someone provide me with a working rule that redirects to https://www.domain.com in case the request is without WWW and/or via HTTP.

I have been made a question months ago like it and answers may help you. Look at:

How to create a EXCEPT Rewrite Rule at IIS

I solved installing Rewrite module and creating a rule inside it. To install, you have to install:

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

The problem was that I didn't have a certificate for the naked domain, only for www.mydomain.com. So when I was redirecting visitors from domain.com to www.domain.com the browser would still verify the certificate (missing) of the naked domain, and stop the redirect to show the warning screen.

Problem was fixed by simply adding the naked domain to my certificate.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM