title: Nginx - Rewriting url to $url.php, and if doesn't exist, rewrite to $url/
body: <p>I run a Wordpress site with some custom php pages as well.</p>
  
  <p>If the url doesn't end in an extension (<code>http://example.com/test</code>) for example, I would like Nginx to try to rewrite it to <code>http://example.com/test.php</code> first, and if <code>test.php</code> doesn't exist, rewrite it to <code>http://example.com/test/</code>.</p>
  
  <p>How can I accomplish this?</p>