Configure web.config to redirect non-www requests to www for multi-site Drupal 7 Install I have a multi-site Drupal 7 install running on Azure that I would like to force all non-www traffic to the www address for all sites.

I have tried a number of examples from around the web but none of them seem to work.

Here is my current implementation, which looks like it should work, but does nothing.

&lt;rule name="Redirect to www"&gt;
  &lt;match url=".*" /&gt;
  &lt;conditions logicalGrouping="MatchAny"&gt;
    &lt;add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" negate="true" /&gt;
  &lt;/conditions&gt;
  &lt;action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" redirectType="Permanent"/&gt;
&lt;/rule&gt;


To clarify, yes, the above rule is nested inside &lt;configuration&gt; &lt;system.webServer&gt; &lt;rewrite&gt;

I've read about doing the redirect in settings.php but that seems kludgy to me and I'd rather do it right.

Any help would be greatly appreciated.
Some subtle differences between this and the rule above, but this officially works for my multi-site Drupal install on Azure IIS.

&lt;rule name="WWW Rewrite" enabled="true"&gt;
          &lt;match url="(.*)" /&gt;
            &lt;conditions&gt;
                &lt;add input="{HTTP_HOST}" negate="true" pattern="^www\.(.*)$" /&gt;
            &lt;/conditions&gt;
            &lt;action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" /&gt;
&lt;/rule&gt;