RewriteEngine On
RewriteBase /

# ---------- PERFORMANCE : COMPRESSION GZIP / DEFLATE ----------
<IfModule mod_deflate.c>
    # Active la compression pour les contenus texte
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml application/rss+xml application/font-woff2
</IfModule>

# ---------- PERFORMANCE : CACHE NAVIGATEUR POUR LES FICHIERS STATIQUES ----------
<IfModule mod_expires.c>
    ExpiresActive On

    # Images
    ExpiresByType image/jpg "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"

    # CSS & JS
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"

    # Fonts
    ExpiresByType application/font-woff "access plus 1 year"
    ExpiresByType application/font-woff2 "access plus 1 year"
    ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
    ExpiresByType font/ttf "access plus 1 year"
    ExpiresByType font/otf "access plus 1 year"
</IfModule>

# Headers Cache-Control pour les assets
<FilesMatch "\.(ico|jpe?g|png|gif|webp|css|js|woff2?|ttf|otf|svg)$">
    <IfModule mod_headers.c>
        Header set Cache-Control "public, max-age=2592000"
    </IfModule>
</FilesMatch>

# ---------- ROUTAGE : LAISSE LES FICHIERS / DOSSIERS EXISTANTS PASSER ----------
# Si le fichier ou dossier demandé n'existe pas
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Redirige tout le reste vers index.php (routing principal)
RewriteRule ^ index.php [QSA,L]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81___lsphp .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
