<IfModule mod_rewrite.c>
    RewriteEngine On

    # Pass Authorization header through to PHP (required for some environments)
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # ADMS / ZKTeco requests — explicit route to ensure correct handling
    RewriteRule ^iclock(/.*)?$ index.php [L,QSA]

    # Redirect trailing slashes if not a folder
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send all other requests to the front controller
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>