title: Nginx, ModX, and Friendly URLs (URL re-writing)
body: <p>I'm migrating a number of ModX Evo websites from my old webserver (Debian / Apache / ISPConfig3) to my new webserver (Debian / Nginx / ISPConfig3).</p>
  
  <p>ISPConfig allows you to add Nginx directives to each vhost, and this is where I've added the following code:</p>
  
  <pre><code>if ($http_user_agent ~* "internal dummy connection") {
    return 403;
  }
  
  location /manager {
  }
  
  location /assets {
  }
  
  location / {
    if (!-f $request_filename) {
      rewrite ^(.*)$ /index.php?q=$1;
    }
  }
  </code></pre>
  
  <p>When I turn Friendly URLs <em>and</em> Friendly Aliases on, and set my preferred suffix to .html, then preview a given page (e.g. <a href="http://example.com/friendly-url.html" rel="nofollow">http://example.com/friendly-url.html</a>), the browser attempts to serve up an HTML page as a download.</p>
  
  <p>(If you download this file and open in a text editor, turns out the file has the exact contents of index.php in the ModX installation root).</p>
  
  <p>What am I doing wrong? How is URL re-writing achieved in nginx? Is this even a URL re-writing issue?</p>
  
  <p>Thanks!</p>