Options -MultiViews
RewriteEngine On

# 1. If the request is for an existing directory, serve the directory
RewriteCond %{REQUEST_FILENAME} !-d

# 2. If the request is for an existing file (like an image or CSS), serve the file
RewriteCond %{REQUEST_FILENAME} !-f

# 3. Otherwise, silently append .php to the URL in the background
RewriteRule ^([^\.]+)$ $1.php [NC,L]