# =====================================================================
#  OTOMIXX — configuration Apache / LiteSpeed (o2switch, cPanel…)
# =====================================================================
Options -Indexes
DirectoryIndex index.html

# --- HTTPS obligatoire -------------------------------------------------
# Le service worker (mode hors ligne) et l'installation de la PWA
# n'existent qu'en HTTPS. Activer d'abord le certificat (AutoSSL /
# Let's Encrypt dans cPanel), sinon cette redirection bouclerait.
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# --- Types MIME -------------------------------------------------------
AddType application/manifest+json .webmanifest
AddType text/javascript .js .mjs
AddType font/woff2 .woff2
AddType font/woff .woff
AddType image/svg+xml .svg

# --- Compression ------------------------------------------------------
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json application/manifest+json image/svg+xml
</IfModule>

# --- Cache ------------------------------------------------------------
<IfModule mod_headers.c>
  # Fichiers dont le nom contient une empreinte (assets/…) : 1 an
  <FilesMatch "\.(js|css|woff2?)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  # Toujours revérifiés, pour que les mises à jour arrivent tout de suite
  <FilesMatch "^(index\.html|sw\.js|registerSW\.js|manifest\.webmanifest)$">
    Header set Cache-Control "no-cache"
  </FilesMatch>
  Header always set X-Content-Type-Options "nosniff"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
