title: Redirect URL to PHP only if file does not exist with Nginx
body: <p>I am trying to get Nginx to rewrite URL space ./data/(.+).png to serveImage.php?guid=$1</p>
  
  <pre><code>server {
      server_name my.server;
      listen 80;
      listen 127.0.0.1:80;
      root /var/www/my.server;
      index index.html;
  
      location / {
          try_files $uri $uri/ index.html;
          rewrite ^/data/(.+).png serveImage.php?guid=$1 last;
      }
  
      location ~ \.php$ {
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param HTTPS off;
      }
  }
  </code></pre>
  
  <p>What am I doing wrong? <code>serveImage.php</code> does exist in the document root.</p>