title: Nginx location match all file extensions except php
body: <p>I have the following in my nginx config file, it works, but I don't want to have to list every file extension.</p>
  
  <pre><code>location ~ \.(gif|jpg|png|css|js|ttf|woff|html|htm|unity3d) {
      try_files $uri /images/default.gif;
  }
  </code></pre>
  
  <p>Is there a way to apply this to everything except php files?</p>
  
  <p><strong>Edit: Updated Config</strong></p>
  
  <p>The main file:</p>
  
  <pre><code>server{
      listen 80 default_server;
  
      server_name    _;
      root           /usr/share/nginx/html/$http_host;
      index          index.php index.html index.htm;
  
  #    location ~ \.(gif|jpg|png|css|js|ttf|woff|html|htm|unity3d|tpl) {
  #        try_files $uri /images/default.gif =404;
  #    }
  
      location ~ .+(?&lt;!\.php)$ {
          location ~ ^[^.]+\.[^.]+$ {
              try_files $uri /images/default.gif =404;
          }
  
          location ~ / {
              try_files $uri $uri/ /index.html;
              include /usr/share/nginx/conf/mission13.io.conf;
          }
  
      }
  
      location ~ \.php$ {
          fastcgi_pass unix:/var/run/php5-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  }
  </code></pre>
  
  <p>Then in the included file:</p>
  
  <pre><code>if ($http_host = groups.mission13.io) {
      rewrite ^(.+)$ /index.php?path=$1;
  }
  </code></pre>