Exposed .env files, .git folders and backups
Make sure files that hold passwords, keys or your source code can never be downloaded from your website.
What it is
Files like .env, the .git folder, config backups and server status pages sometimes end up in the public web folder by accident.
Why it matters
They often contain database passwords and API keys, or let anyone download your full source code and its history. Bots scan the whole internet for them every day.
How to fix it
location ~ /\.(?!well-known) { deny all; }
<FilesMatch "^\."> Require all denied </FilesMatch>
# keep secrets out of the web root and out of git echo ".env" >> .gitignore # deploy a build folder, not the repository checkout
If a secret was ever reachable, treat it as stolen: change the password or rotate the key, even after you block the file.
Does your site have this problem?
Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.