Fancy URL (remove .php extension)

I have a haproxy server and everything is working. But i just need to remove the extension from the url like that:

http://test.com/login.php?testvars=123

to

http://test.com/login?testvars=123

Before it was working over .htaccess with this code:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

But since i proxy through haproxy it doesnt work anymore

Any help appreciated.