# ====================================================================
#  BOMAN STORE — .htaccess raíz del sitio
#  URLs amigables: /producto/{slug}  →  producto.php?slug={slug}
# ====================================================================

RewriteEngine On

# Si ya existe un archivo o carpeta real con ese nombre, servirlo tal cual
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# /producto/nombre-del-producto  →  producto.php?slug=nombre-del-producto
RewriteRule ^producto/([a-zA-Z0-9\-]+)/?$ producto.php?slug=$1 [L,QSA]

# ── Opcional: rutas cortas para otras páginas ya desarrolladas ──
# /catalogo   → catalogo.php
# /checkout   → checkout.php
# /tracking   → tracking.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^catalogo/?$ catalogo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^checkout/?$ checkout.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^tracking/?$ tracking.php [L,QSA]

# ====================================================================
#  Seguridad básica
# ====================================================================

# Bloquear acceso directo a archivos de configuración sensibles
<FilesMatch "^(db\.local\.php|migration.*\.sql)$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>
