# Enable the rewrite engine
RewriteEngine On

# Check if the requested file doesn't exist as a directory
RewriteCond %{REQUEST_FILENAME} !-d

# Check if the requested file with .php extension exists
RewriteCond %{REQUEST_FILENAME}.php -f

# Rewrite the URL to add .php extension internally
RewriteRule ^(.*)$ $1.php [L]

# Optional: Redirect requests with .php to clean URLs (without .php)
# Uncomment these lines if you want to enforce clean URLs
# RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
# RewriteRule ^ /%1 [R=301,L,NE]