RewriteEngine On

# ---------------------------------
# 1. Forzar HTTPS
# ---------------------------------
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# ---------------------------------
# 2. Permitir assets y api
# ---------------------------------
RewriteCond %{REQUEST_URI} ^/kpis-in\.dalegip\.com/public/assets/ [OR]
RewriteCond %{REQUEST_URI} ^/kpis-in\.dalegip\.com/public/api/
RewriteRule ^ - [L]

# ---------------------------------
# 3. Permitir archivos públicos explícitos
# ---------------------------------
RewriteCond %{REQUEST_URI} ^/kpis-in\.dalegip\.com/public/(index|login|logout)\.php$
RewriteRule ^ - [L]

# ---------------------------------
# 4. Redirigir cualquier otro acceso a index.php
# ---------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]