Replacing the php regex with try_files?

Hi all,

Right now I use this type of configuration:

        location / {
                try_files               $uri $uri/
/index.php?q=$uri&$args;
        }
        location ~ \.php$ {
                fastcgi_pass            127.0.0.1:9000;
                include                 fastcgi.conf;
        }

My goal is to eliminate the regex on php file names:

        location / {
                try_files               $uri $uri/ @php;
        }
        location @php {
                try_files               $uri.php /index.php?q=$uri&$args
/404.html;
                fastcgi_pass            127.0.0.1:9000;
                include                 fastcgi.conf;
        }

I’m not sure if this is the correct way to do it. Any suggestions are
welcome.

Posted at Nginx Forum: