Nginx: Call php without extension

PHOTO EMBED

Mon Aug 29 2022 18:45:16 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #php #nginx

server{
    :
    
    location / {
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      try_files $uri $uri/ @extensionless-php;
    }

    location @extensionless-php {
      if ( -f $document_root$uri.php ) {
        rewrite ^ $uri.php last;
      }
      return 404;
    }
    
    :
}
content_copyCOPY

Configuration in nginx to call php scripts without using .php extension at URI.