title: Azure redirect non-www to www
body: <p>I have question about Azure redirection.</p>
  
  <p>I have searched other topics but not quite my problem(s).</p>
  
  <p>I have ASP.NET Core 2.2 project and Azure configured for that. Also i have domain for pointing to Azure.
  I have added www.example.com format domain to azure and that works fine also with https.</p>
  
  <p>Problem rises with example.com format </p>
  
  <p>I wanted to redirect example.com format to www.example.com URL</p>
  
  <p>I manage to get this work with this, but for little while.
  I use this web.config for redirection</p>
  
  <p>web.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false"/&gt;
      &lt;rewrite&gt;
        &lt;rules&gt;
          &lt;rule name="CanonicalHostNameRule" stopProcessing="true"&gt;
            &lt;match url="(.*)" /&gt;
            &lt;conditions&gt;
              &lt;add input="{HTTP_HOST}" pattern="^example.com$" /&gt;
            &lt;/conditions&gt;
            &lt;action type="Redirect" url="https://www.example.com/{R:0}" /&gt;
          &lt;/rule&gt;
        &lt;/rules&gt;
      &lt;/rewrite&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  
  </code></pre>
  
  <p>Something strange is Google Chrome &amp; Opera redirect(s) to www domain but not Edge and Firefox.
  Then when i clear cache(s) then it wont redirect.</p>
  
  <p>Seems like Azure like rewrites some over or something.</p>
  
  <p>Thanks for help!! </p>