title: Forcing all pages to be ssl except for the root page
body: <p>I am currently using </p>
  
  <pre><code>location / {
    if ($ssl_protocol = "")
    {
      rewrite ^ https://$host$request_uri? permanent;
    }
  }
  </code></pre>
  
  <p>in my nginx conf. This successfully forces all pages to be https. However, I would like the root page and only the root page (aimed at index.htm) to be optionally http so that when the user goes to <a href="http://myserver.com" rel="nofollow">http://myserver.com</a> it will not redirect to https. How can I do this?</p>
  
  <p>(I am able to selectively not use ssl on certain subdirectories, by specifying their location, e.g., /nossl would allow <a href="http://myserver.com/nossl" rel="nofollow">http://myserver.com/nossl</a> to be not ssl). If the user goes to <a href="http://myserver.com/somepage.htm" rel="nofollow">http://myserver.com/somepage.htm</a> I would want it to redirect.</p>