RewriteEngine On
RewriteBase /v1/

# ----- 1) Direct public .php access block -----
# RewriteCond %{REQUEST_URI} ^/v1/(gateway|client)/ [NC]
# RewriteCond %{THE_REQUEST} \s/+.*\.php[?\s] [NC]
# RewriteRule ^ - [R=404,L]

# ----- 2) .php extension auto add for gateway/client -----
RewriteCond %{REQUEST_URI} ^/v1/(gateway|client)/ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(gateway|client)/(.*)$ $1/$2.php [L,QSA]

<Files "config.php">
  Order Allow,Deny
  Deny from all
</Files>