title: nginx "try_files" directive is not allowed here
body: <p>What I want to achieve is pretty simple :</p>
  
  <p><strong>If the subdomain starts with <code>admin</code>, try to serve directly from controller <code>admin.php</code> for all other cases, try to serve files with <code>site.php</code>.</strong></p>
  
  <p>Note that I don't know domain names as a lot of domains are pointing to us.
  What I tried so far: </p>
  
  <pre><code>server {
      listen 8080;
      root /path/to/current/web;
  
      location / {
          if ($http_host ~ "^admin") {
              try_files $uri @rewriteadmin;
          }
          if ($http_host !~ "^admin") {
              try_files $uri @rewriteapp;
          }
      } 
  
      location @rewriteapp {
          rewrite ^(.*)$ /site.php/$1 last;
      }
  
      location @rewriteadmin {
          rewrite ^(.*)$ /admin.php/$1 last;
      }
      ...
   }
  </code></pre>
  
  <p>Of course this setup doesn't work and gives me : <code>[emerg] "try_files" directive is not allowed here</code>.</p>
  
  <p>What's the best practice to achieve that please ? </p>