# Activer le moteur de réécriture
RewriteEngine On

# Forcer HTTPS + WWW si la requête ne l'est pas déjà
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

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

# Réécriture pour permettre d'accéder à un fichier sans mettre .php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# Redirection automatique de index.php vers /
DirectoryIndex index.php
