IIS Url Rewrite rule HTTP to HTTPS AND add WWW

2019-09-19 04:03发布

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.

2条回答
贼婆χ
2楼-- · 2019-09-19 04:14

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.

查看更多
Animai°情兽
3楼-- · 2019-09-19 04:26

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

查看更多
登录 后发表回答