RewriteEngine On

# Redirect URLs with .php extension to same URL without extension
RewriteCond %{THE_REQUEST} \s/+(.+)\.php [NC]
RewriteRule ^ /%1 [R=301,L]

# Rewrite requests to append .php extension internally
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
