IIS Url Rewrite rule HTTP to HTTPS AND add WWW

二次信任 提交于 2019-12-11 15:47:06

问题


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.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/30537218/iis-url-rewrite-rule-http-to-https-and-add-www

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!