<IfModule mod_rewrite.c>
    RewriteEngine On

    # Redirect direct requests to index.php to the base URL
    RewriteCond %{THE_REQUEST} \s/index\.php [NC]
    RewriteRule ^index\.php$ ./ [R=302,L]

    # If the requested file or directory exists, serve it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    # Otherwise, route everything to index.php
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

