title: azure web app : www to non www https
body: <p>I have an Azure web application and need help with enforcing https.</p>
  
  <p><a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a> to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></p>
  
  <p><a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a> to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></p>
  
  <p>www.example.com to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></p>
  
  <p>example.com to <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></p>
  
  <p>The current <strong>web.config</strong> is as below. This does not work for <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a> -> <a href="https://example.com" rel="nofollow noreferrer">https://example.com</a></p>
  
  <pre><code>&lt;rules&gt;
  
  
          &lt;!-- Force HTTPS for all requests --&gt;
          &lt;rule name="HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true"&gt;
            &lt;match url="*" /&gt;
            &lt;conditions&gt;
              &lt;add input="{HTTPS}" pattern="off" /&gt;
            &lt;/conditions&gt;
            &lt;action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" /&gt;
          &lt;/rule&gt;
  
  
          &lt;!-- Redirect all requests to non www--&gt;
          &lt;rule name="WWW" stopProcessing="true"&gt;
            &lt;match url="^(.*)$" /&gt;
            &lt;conditions&gt;
              &lt;add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" /&gt;
            &lt;/conditions&gt;
            &lt;action type="Redirect" url="https://example.com{PATH_INFO}" /&gt;
          &lt;/rule&gt;
  
  &lt;/rules&gt;
  </code></pre>