On my Windows 2012 server I have installed the URL Rewrite module in IIS. I have followed this guide to redirect non-www to www in web.config: http://www.surfingsuccess.com/asp/iis-url-rewrite.html#.VF6GBid0yAU
So far, so good!
The only problem is that we also host the subdomain "api.example.com". This API stops working when I apply the code in web.config.
My question is: What is wrong with the code below? Why does the subdomain stop working when I try to redirect non-www to www, except "api.example.com"?
<rewrite><rules><rule name="CanonicalHostNameRule1"><match url="(.*)" /><conditions><add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" /><add input="{HTTP_HOST}" pattern="^api\.example\.com$" negate="true" /></conditions><action type="Redirect" url="http://www.example.com/{R:1}" /></rule></rules></rewrite>