<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Default index
    DirectoryIndex index.php

    # If accessing index.php directly, allow it
    RewriteRule ^index.php$ - [L]

    # --- NEW: Redirect directory access (if no index.php inside) to root index.php ---
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{REQUEST_FILENAME}/index.php !-f
    RewriteRule ^.*$ /index.php [L,R=302]
    # -------------------------------------------------------------------------------

    # If the file or directory does not exist, route to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

~

