This rewrite rule works just fine to remove .php extension, but in the case where a file name is passed in the query string, it tries to remove the extension there too. How to make it ignore the query string?
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
(.*)\.php$will never match if.phpis only in the querystring. So the two combined should never, ever, match a url with only.phpin the querystring.