location ~ (^/test$|test.php$)
    {
        rewrite ^/(^/test$) /$1.php last;
        include fastcgi.conf;
        fastcgi_pass unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
    }

这样访问test时实际访问的是test.php。