尾部斜杠会导致页面到404

I have a site that's built with PHP and I'm using the .htaccess file to remove the .php extension.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

This works fine and means that I can access /file.php by doing /file. However if I put a trailing slash at the end of the URL I get a 404 error. I've tried quite a few things but I can't get it work. Does anyone know what I'm doing wrong?

You can use this .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+?)/?$ $1.php [NC,L]