Htaccess mod rewrite question

I use this code to rewrite to

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\\.php -f
RewriteRule ^(.*)$ $1.php

How can i redirect this: to

I’m confused. You want some code but you’re already showing the code you have (which does what you describe) and then ask us what you need?
From what I can see you already have what you need, or am I missing something?

you could try this code for redirect file(s).php to file(s) :
RewriteEngine On
RewriteRule ^(.*)\.php $1


RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.php $1 [R=301,L]


simply change rewrite rule on the contrary without RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).php$ $1

My code is not working and I get 500 internal server error and I don’t why this happen

I don’t know either; it works for me when I put it in my .htaccess.
Is there more code in that .htaccess? Are you sure is raising the 500 internal server error, and not the php application?