<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Block access to hidden files (.env, .git, etc.)
    RewriteRule ^\.(?!well-known).* - [F,L]

    # Block sensitive files from direct web access
    RewriteRule ^(\.env|\.git|composer\.(json|lock)|package(-lock)?\.json|artisan|phpunit\.xml|vite\.config\.js|README.*|\.editorconfig) - [F,L,NC]

    # Block access to core Laravel code folders
    RewriteRule ^(app|bootstrap|config|database|resources|routes|tests|vendor)($|/) - [F,L,NC]

    # Forward all requests to public/
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteCond %{REQUEST_URI} !public/
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

# Security headers for shared cPanel hosting
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>
