I am trying to use <system.webServer><rewrite> to enforce WWW but i keep getting the mentioned error "which indicates the xml is malformed" whenever I load the site. The error is raised from the whole <rewrite> block "surrounded by comments".
I tried online web.config validator and it didn't show any errors.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<!--Enfore WWW Problem Here-->
<rewrite>
<rules>
<clear />
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\.(.*)$" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<!--Enfore WWW Problem Here-->
</system.webServer>
</configuration>
User contributions licensed under CC BY-SA 3.0