<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On

    # Prevent direct access to sensitive core folders and files
    RewriteRule ^(\.env|\.git|composer\.(json|lock)|package(-lock)?\.json|symfony\.lock|var/|vendor/|config/|src/|templates/) - [F,L]

    # Fallback to the public/index.php Symfony entry point
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ public/index.php [QSA,L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        RedirectMatch 302 ^/$ /index.php/
    </IfModule>
</IfModule>
