title: Nginx 301 Redirect all non home page urls to home page
body: <p>I'm shutting down a site and I need to 301 redirect all pages to the home page where I have a message saying that the site is being closed down.</p>
  
  <p>Basically any <a href="http://example.com/anyfolder" rel="nofollow">http://example.com/anyfolder</a> -> 301 to <a href="http://www.example.com" rel="nofollow">http://www.example.com</a></p>
  
  <p>I have the following but this results in a redirection loop.</p>
  
  <pre><code>location ~ ^/([A-z]+) { rewrite ^ / permanent; }
  </code></pre>
  
  <p>What is the proper way to do this in nginx?</p>