# ===========================
# ACTIVAR REWRITE ENGINE
# ===========================
RewriteEngine On

# ===========================
# REESCRIBIR URLs para PHP
# ===========================
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

# ===========================
# TRATAR HTML COMO PHP
# ===========================
AddType application/x-httpd-php .html .htm

# ===========================
# BLOQUEAR ACCESO A ARCHIVOS DE BASE DE DATOS
# ===========================
<FilesMatch "\.db\.db$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# ===========================
# BLOQUEO SELECTIVO PARA NAVEGADORES
# ===========================
<FilesMatch "\.(php)$">
    # Bloquear si es un navegador común (Mozilla, Chrome, Safari, Firefox)
    <If "%{HTTP_USER_AGENT} =~ /Mozilla|Chrome|Safari|Firefox/i">
        Require all denied
    </If>
</FilesMatch>

# ===========================
# Nota:
# Tu app Android puede acceder a la carpeta api, 
# mientras que un usuario de navegador recibirá 403 si intenta abrir archivos directamente.
# ===========================