title: Nginx: rewrite all subdomains to www except for one?
body: <p>Suppose I have a pair of servers that, due to the way things get deployed, need to use the same <code>nginx.conf</code>. One of the servers is at <code>staging.someserver.com</code>, and the other is at <code>www.someserver.com</code>.</p>
  
  <p>What I want is a single rewrite line or an if condition that will redirect everything on the domain (mainly www and non-www on http, and non-www on https) to <code>https://www.someserver.com/</code>, and for <code>http://staging.someserver.com/</code> to redirect to <code>https://staging.someserver.com/</code>, but not to <code>https://www.someserver.com/</code>. How can I do this?</p>