title: https://www.subdomain.domain.com to https://subdomain.domain.com redirect
body: <p>My boss wants to ensure that our internet-challenged users will be able to reach a particular subdomain (<a href="https://subdomain.domain.com" rel="nofollow noreferrer">https://subdomain.domain.com</a>) by typing it into their browser's address bar as:</p>
  
  <p><a href="https://www.subdomain.domain.com" rel="nofollow noreferrer">https://www.subdomain.domain.com</a> </p>
  
  <p>It seems I am able to do the HTTP -> HTTPS redirect without issue using IIS's Rewrite module.  Also it seems I am able to do the WWW.subdomain.domain.com to subdomain.domain.com with the rewrite module.  However, combining them is proving difficult.  So, it's when the user types in their browser <a href="https://www.subdomain.domain.com" rel="nofollow noreferrer">https://www.subdomain.domain.com</a> that ultimately fails with a privacy warning (our wildcard cert is for *.domain.com).</p>
  
  <p>I've got a CNAME record set up pointing www.subdomain.domain.com to the A record for subdomain.domain.com.  I've got the bindings in IIS set up for each of the 4 combinations (with/without https, with/without www).</p>
  
  <p>I have the following in the config for the site: </p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;rewrite&gt;
            &lt;rules&gt;
              &lt;clear /&gt;
              &lt;rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="false"&gt;
                      &lt;match url="*" /&gt;
                      &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="false"&gt;
                          &lt;add input="{CACHE_URL}" pattern="*://www.*" /&gt;
                      &lt;/conditions&gt;
                      &lt;action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" /&gt;
                  &lt;/rule&gt;
                  &lt;rule name="http to https" stopProcessing="true"&gt;
                      &lt;match url="(.*)" /&gt;
                      &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="true"&gt;
                          &lt;add input="{HTTPS}" pattern="^OFF$" /&gt;
                      &lt;/conditions&gt;
                      &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" /&gt;
                  &lt;/rule&gt;
              &lt;/rules&gt;
          &lt;/rewrite&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>Still it seems that I can't get the browser to like the redirect from the <a href="https://www.subdomain.domain.com" rel="nofollow noreferrer">https://www.subdomain.domain.com</a> to <a href="https://subdomain.domain.com" rel="nofollow noreferrer">https://subdomain.domain.com</a>.  Why isn't the rewrite taking care of this before the browser attempts to serve www.subdomain.domain.com.  Is this even possible??</p>