Options -Indexes
RewriteEngine On

# Always serve the current application shell after an update.
<IfModule mod_headers.c>
  <FilesMatch "^index\.html$">
    Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
    Header set Pragma "no-cache"
    Header set Expires "0"
  </FilesMatch>
</IfModule>

# ── Base del subdirectorio ────────────────────────────────────────────────────
# IMPORTANTE: Si la app está en /podoclinic/, mantener esta línea.
# Si está en la raíz (/), cambiar a: RewriteBase /
RewriteBase /podoclinic/

# ── CORS preflight (OPTIONS) ─────────────────────────────────────────────────
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^.*$ - [R=204,L]

# ── API routes → PHP handlers (sin condición !-f para que siempre funcionen) ──
RewriteRule ^api/auth/?$         api/auth.php    [QSA,L]
RewriteRule ^api/crud/?$         api/crud.php    [QSA,L]
RewriteRule ^api/special/?$      api/special.php [QSA,L]

# ── SPA fallback: solo si NO es archivo/directorio real ─────────────────────
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$               index.html      [QSA,L]

# ── Seguridad: bloquear acceso a archivos sensibles ──────────────────────────
<FilesMatch "\.(sql|log|env|bak)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# ── PHP settings (cPanel) ────────────────────────────────────────────────────
php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 120
php_value memory_limit 256M
