# ════════════════════════════════════════════════════════════════════════
#  INTRO CMS — Apache / LiteSpeed
# ════════════════════════════════════════════════════════════════════════

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Forzar HTTPS (descomenta en producción con SSL)
    # RewriteCond %{HTTPS} off
    # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # No reescribir archivos/carpetas reales
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Todo lo demás → index.php (front controller)
    RewriteRule ^ index.php [L]
</IfModule>

# ─── Cabeceras de seguridad ───────────────────────────────────────────────
<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
    Header unset X-Powered-By
</IfModule>

# ─── Compresión ───────────────────────────────────────────────────────────
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json image/svg+xml
</IfModule>

# ─── Caché de assets estáticos ────────────────────────────────────────────
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp        "access plus 1 year"
    ExpiresByType image/jpeg        "access plus 1 year"
    ExpiresByType image/png         "access plus 1 year"
    ExpiresByType image/svg+xml     "access plus 1 year"
    ExpiresByType text/css          "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType font/woff2        "access plus 1 year"
</IfModule>

# ─── Proteger archivos sensibles ──────────────────────────────────────────
<FilesMatch "(^config\.php|\.sqlite|\.schema_version|composer\.(json|lock))$">
    Require all denied
</FilesMatch>

# Bloquear acceso directo a /core, /data y /config
RedirectMatch 403 ^/?(core|data|config)/.*$

Options -Indexes
