Fix · nginx
Fix “Exposed .env file” on nginx
Remove .env from the web root, block dotfiles at the server, and ROTATE every secret that was exposed -- assume it is compromised.
location ~ /\.(?!well-known).* { deny all; }
Verify the fix
Re-run the Exposed .env file check after deploying. Test config changes in staging first and keep a rollback: a wrong header can break a site faster than a missing one.
Other stacks: Apache · Caddy · Express / Node · Cloudflare