Ok so I understood I need to add this custom configuration in the web.config using XDT:Transform
.
I added this to the Web.Release.config
and it worked:
<system.webServer>
<rewrite xdt:Transform="Insert">
<rules>
<rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="mydomain.com" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>