在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>
05-08 14:50