Options -Indexes
DirectoryIndex index.php

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Desafíos del hosting y archivos ocultos.
    RewriteCond %{REQUEST_URI} !^/\.well-known/
    RewriteRule (^|/)\. - [F,L]

    # Archivos privados: config, tools, datos y librerías de los módulos.
    RewriteRule ^(config(\.example)?\.php|tools|datos)(/|$) - [F,L,NC]
    RewriteRule ^mod-(espacios|captador)/(lib|config|datos|tools)(/|$) - [F,L,NC]

    # Archivos reales (assets, PWA) se sirven tal cual.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]

    # Carpetas con index.html (PWA en /app).
    RewriteCond %{REQUEST_FILENAME}/index.html -f
    RewriteRule ^(.*)$ $1/index.html [L]

    # Todo lo demás va al router unificado.
    RewriteRule ^ index.php [L]
</IfModule>

# La PWA se actualiza sola: su HTML/JS no se queda cacheado por años.
<IfModule mod_headers.c>
    <FilesMatch "\.(html|js|json|webmanifest)$">
        Header set Cache-Control "no-cache, must-revalidate"
    </FilesMatch>
</IfModule>
