# Nuvio Panel - regole compatibili con hosting condiviso cPanel/Apache/LiteSpeed.
# Non forza alcun handler PHP: la versione PHP viene scelta dal pannello cPanel.

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Espone Authorization a PHP sui server CGI/FastCGI quando necessario.
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Rotte API senza estensione: api/auth/login -> api/auth/login.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.+?)/?$ $1.php [L]
</IfModule>

<IfModule mod_setenvif.c>
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</IfModule>

# Protezione di eventuali database finiti per errore nella cartella pubblica.
<FilesMatch "\.(sqlite|sqlite-wal|sqlite-shm|db)$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>
