1. Nếu sử dụng Wildcards, trong section <system.webServer> của file web.config, thêm đoạn sau:
<rewrite>
<rules>
<rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="domain.com" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}" />
</rule>
</rules>
</rewrite>
2. Nếu sử dụng Regular Expressions, ta dùng như sau:
<rewrite><rules><rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true"><match url=".*" /><conditions><add input="{HTTP_HOST}" pattern="^domain.com$" /></conditions><action type="Redirect" url="http://www.domain.com/{R:0}" /></rule></rules></rewrite>