# ludiWARE public root
Options -Indexes

RewriteEngine On

# Forcer HTTPS (sauf localhost)
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteCond %{HTTP_HOST} !^localhost(:\d+)?$ [NC]
RewriteCond %{HTTP_HOST} !^127\.0\.0\.1(:\d+)?$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Zones protégées / pass-through
RewriteRule ^lw-admin(/|$) - [L]
RewriteRule ^database(/|$) - [F,L]
RewriteRule ^uploads(/|$) - [L]
RewriteRule ^functions(/|$) - [F,L]

# Fichiers / dossiers réels
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Tout le reste → index.php (routes /s/{slug}/…)
RewriteRule ^(.*)$ index.php?lw_route=$1 [QSA,L]
