Options -MultiViews
RewriteEngine On

# ── PHP handler — targetting ea-php81 as confirmed in cPanel settings ──
<FilesMatch "\.php$">
    # Try the most likely cPanel handlers first
    SetHandler application/x-httpd-ea-php81
    AddHandler application/x-httpd-ea-php81 .php
    AddHandler application/x-httpd-php81 .php
    
    # Fallbacks
    AddHandler application/x-httpd-ea-php82 .php
    AddHandler application/x-httpd-ea-php80 .php
    AddHandler application/x-httpd-php .php
</FilesMatch>

# ── SPA routing — send non-file, non-PHP requests to React ──
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.php$
RewriteRule ^ index.html [QSA,L]

# ── Deny .env ──
<FilesMatch "^\.env">
    Order allow,deny
    Deny from all
</FilesMatch>

# ── Gzip ──
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json
</IfModule>

# ── Cache static assets, but NOT logos (force refresh) ──
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresByType text/css   "access plus 7 days"
    ExpiresByType application/javascript "access plus 7 days"
</IfModule>

# Force no-cache on images/logos so updated logos always appear
<IfModule mod_headers.c>
    <FilesMatch "\.(png|jpg|jpeg|webp|svg)$">
        Header set Cache-Control "no-cache, must-revalidate"
    </FilesMatch>
</IfModule>