<IfModule mod_rewrite.c>
    RewriteEngine On

    # 🔒 Forcer HTTPS + www (en une seule redirection)
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # 🤖 Bloquer certains bots indésirables
    RewriteCond %{HTTP_USER_AGENT} (AhrefsBot|MJ12bot|SemrushBot|DotBot|BLEXBot|YandexBot|Bytespider|GPTbot) [NC]
    RewriteRule .* - [F,L]

    # 📁 Si le fichier ou le dossier existe, ne rien faire
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # 🔁 Sinon, rediriger vers index.php
    RewriteRule ^ index.php [QSA,L]
</IfModule>
