IIS7 rewrite http and http://www to https

和自甴很熟 提交于 2019-12-11 07:49:28

问题


I switched my application to https. I added system.webServer rewrite rule

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>

in my web.config

It rewrites http://mydomain.com to https://mydomain.com which is good. Bot how to make it to rewrite also http://www.mydomain.com to https://mydomain.com (without www)


回答1:


  1. You could make a separate rule that changes the www.mydomain.com into mydomain.com

  2. You could just hardcode your http_host and instead of using {HTTP_HOST} simply put there: "mydomain.com" so

    <action type="Redirect" redirectType="Found" url="https://mydomain.com/{R:1}" />



来源:https://stackoverflow.com/questions/6358996/iis7-rewrite-http-and-http-www-to-https

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