Exposed config files: check, fix, prevent.
Step-by-step fixes for the files DotenvScan checks — .env, wp-config.php backups and .git — with web-server rules tested on real nginx, Apache and Caddy servers, and background on the files themselves.
Fix an exposed file
Your .env file is exposed. Here’s what to do now.
Block it in nginx, Apache or Caddy, rotate every secret in it, check your logs, and move it out of the web root.
Your wp-config.php backup is public. Here’s how to fix it.
A .bak or .save copy of wp-config.php gives away the database password and keys. Block it, change them, check for intruders.
Laravel .env exposed: fix it, and rotate APP_KEY safely.
Point the web root at public/, rotate in the right order, change APP_KEY without breaking encrypted data, and turn off debug mode.
An exposed .git directory gives away your source code.
If /.git/ is reachable, your code, history and old secrets can be rebuilt. Check it, block it, rotate, and deploy without it.
A public phpinfo() page gives away your server’s secrets.
A leftover phpinfo() test page prints server paths, request headers and environment variables. Remove it, disable it, rotate.
Other dotfiles that leak: .aws/credentials, .svn and .DS_Store.
AWS keys, Subversion working copies and macOS .DS_Store files in the web root: what each leaks, and one rule for all of them.
NEXT_PUBLIC_ and VITE_ variables are public. Keep secrets out of them.
Front-end tools ship NEXT_PUBLIC_, VITE_ and similar variables to every visitor. What is safe, and how to check your bundle.
Explainers
What is a .env file? Format, examples, and keeping it private.
What a .env file is, env file examples for Node, Python, Laravel and Docker, the syntax rules, and how it ends up public.
phpinfo(): what it shows, and how to check PHP settings safely.
How to make a phpinfo.php page, what each section shows, command-line alternatives, and why it must not stay online.
wp-config.php: what’s in it, where it is, and how to secure it.
Where WordPress’s config file lives, what each line does, the settings worth knowing, and how to keep it from leaking.
Security misconfiguration: what it is, with real examples.
What OWASP’s #2 risk means in practice, thirteen real examples, which ones DotenvScan checks, and how to prevent them.
Related tools
- ServerSecretVault — Runs on a Linux server and finds every .env, wp-config.php and backup copy across all sites and accounts, flags risky permissions and web-root copies, and rates each file’s risk.
- WPSalt — Generates the eight WordPress keys and salts for wp-config.php in your browser, plus WordPress password hashes and .htaccess rules.
- WP Server Guard — Manual WordPress and Linux server security audits and malware removal, with free guides to hacked-site problems.