title: Nginx rewrite only when root domain
body: <p>I'd like to do an Nginx rewrite where I have two domains: domain.com and domain.net with the following rules:</p>
  
  <p>1) If a user goes to <a href="http://www.domain.net/" rel="noreferrer">http://www.domain.net/</a>, he will be redirected to <a href="http://www.domain.com/" rel="noreferrer">http://www.domain.com/</a>
  2) If a user goes to <a href="http://www.domain.net/anything_else.html" rel="noreferrer">http://www.domain.net/anything_else.html</a> the rewrite will not occur.</p>
  
  <p>This is my failed attempt:</p>
  
  <pre><code>server {
    listen 80;
    server_name www.domain.net domain.net;
    location / {
      rewrite / http://www.domain.com/ permanent;
    }
  }
  </code></pre>
  
  <p>The correct format would be much appreciated!</p>