You have a couple errors.
Code:
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
Set canonical domain for www like this.
Code:
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.yourdomain\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.yourdomain.com/{R:1}" />
</rule>