title: Redirecting nginx to index.php
body: <p>I have nginx on a Raspberry Pi.  In <code>/etc/nginx/sites-available/default</code>, I replaced <code>server{}</code> with the following, and I can access <code>/var/www/html/index.php</code> using <a href="http://192.168.1.210/" rel="nofollow noreferrer">http://192.168.1.210/</a>.</p>
  
  <pre><code>server {
          listen 80;
          server_name $domain_name;
          root /var/www/html/;
          index index.html index.htm;
          access_log /var/log/nginx/access.log;
          error_log /var/log/nginx/error.log;
  
          location ~\.php$ {
                  fastcgi_pass unix:/var/run/php5-fpm.sock;
                  fastcgi_split_path_info ^(.+\.php)(/.*)$;
                  fastcgi_index index.php;
                  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                  fastcgi_param HTTPS off;
                  try_files $uri =404;
                  include fastcgi_params;
                  # if (!-e $request_filename){ rewrite ^(.*)$ /index.php break; }
          }
  }
  </code></pre>
  
  <p>I now wish to add some simple redirecting similar to Apache's</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule . index.php [L]
  </code></pre>
  
  <p>I added <code>if (!-e $request_filename){ rewrite ^(.*)$ /index.php break;</code> at the end (see the above commented out line) and placed <a href="http://192.168.1.210/page2" rel="nofollow noreferrer">http://192.168.1.210/page2</a> in the browser, however, the script still doesn't redirect to <code>/var/www/html/index.php</code></p>
  
  <p>How can I redirect any non-existing requests to index.php?</p>