how remove .php extension just one file nginx

My Nginx config is:

location ~ .php$ {
    try_files $uri = 404;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass php-fpm:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_read_timeout 300;
}

`
Now I remove .php from my page for example: exmaple.com/course.php to exmaple.com/course

add

location ~ /course {
 rewrite ^ /course.php
}

but any page url has course redirect to course.php