Options -Indexes

DirectoryIndex index.php

RewriteEngine On

# Redirect explicit .php browser requests to clean URLs.
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php(?:[\s?]|$) [NC]
RewriteRule ^(.+)\.php$ $1 [R=301,L,NE]

# Internally resolve extensionless routes.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/.]+)/?$ $1.php [L,QSA]

<FilesMatch "^(config\.php|config\.example\.php)$">
    Require all denied
</FilesMatch>
