IIS配置web.config 将带www域名转为不带www域名

在configuration节点中添加

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
     <!--http转https-->
        <rule name="Redirect to https" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}:443/{R:1}" redirectType="SeeOther" />
        </rule>
        <!--将带www转为不带www-->
        <rule name="WWW Redirect" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www.xxx.com$"/>
          </conditions>
          <action type="Redirect" url="https://xxx.com/{R:0}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

 

posted @ 2019-10-24 09:12  雨殇丶  阅读(913)  评论(0编辑  收藏  举报