Could you just change your last RewriteRule to do this?
RewriteRule ^(.*)$ $1.php [L,R=301]
This will redirect "myfile" to "myfile.php".
In addition, you can configure this inside Google Analytics using rules. Although this is probably not an ideal solution.
ETA . If you want to redirect myfile.php to myfile, try this instead of the last rule:
RewriteRule ^(.+)\.php$ $1 [L,R=301]
source
share