Fix · Apache
Fix “Exposed .env file” on Apache
Remove .env from the web root, block dotfiles at the server, and ROTATE every secret that was exposed -- assume it is compromised.
<FilesMatch "^\.">
Require all denied
</FilesMatch>
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: nginx · Caddy · Express / Node · Cloudflare