# ==========================================================
# RÉÉCRITURE D'URL PROPRE SANS .PHP (LITESPEED / APACHE / CPANEL)
# ==========================================================
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # 1. Servir directement les fichiers et répertoires physiques réels (CSS, JS, images, SVG...)
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # 2. Rediriger les requêtes directes en .php vers l'URL propre sans .php (ex: /dashboard.php -> /dashboard)
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^?]+)\.php [NC]
    RewriteRule ^ %1 [R=301,L]

    # 3. Réécrire vers le fichier .php si existant
    RewriteCond %{DOCUMENT_ROOT}/$1.php -f [OR]
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php [L,QSA]

    # 4. Routeur universel (Fallback) pour LiteSpeed / Apache
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ router.php [L,QSA]
</IfModule>

DirectoryIndex dashboard.php index.php
