<IfModule mod_rewrite.c>
    RewriteEngine On

    # Disable directory listing
    Options -Indexes

    # Redirect root to /public if not already in /public
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ /kfa_one_click/public/$1 [R=301,L]

    # Prevent access to sensitive files
    <FilesMatch "^(\.env|artisan|composer\.(json|lock)|package\.json|webpack\.mix\.js|phpunit\.xml)$">
        Require all denied
    </FilesMatch>

    RedirectMatch 403 /vendor/
    RedirectMatch 403 /storage/
    RedirectMatch 403 /node_modules/
    RedirectMatch 403 /bootstrap/
    RedirectMatch 403 /config/
    RedirectMatch 403 /database/
    RedirectMatch 403 /tests/
    RedirectMatch 403 /resources/
</IfModule>