RewriteCond %{THE_REQUEST} ([^\s]*)\.php(\?[^\s]*)?
RewriteRule (.*) %1 [R=301,L]
/file1.php
и /folder/file2.php
RewriteCond %{REQUEST_URI} !^/file1\.php
RewriteCond %{REQUEST_URI} !^/folder/file2\.php
RewriteCond %{THE_REQUEST} ([^\s]*)\.php(\?[^\s]*)?
RewriteRule (.*) %1 [R=301,L]