On this page
What this issue is
WordPress keeps its database host, name, user, password and security keys in wp-config.php. The server runs this file as PHP, so visitors only see a blank page. But if someone copies it to wp-config.php.bak, wp-config.php~, wp-config.old, wp-config.txt or wp-config.php.save, the server no longer treats it as PHP. It sends the raw text to anyone who asks for it.
Why it costs you leads or sales
- Backup copy savedwp-config.php.bak left in web root
- File is publicServed as plain text
- Credentials readDB password and keys exposed
- Data accessedLeads and orders at risk
The break is the public copy of the config file. Everything after it is at risk.
How to check if your site has it
for f in wp-config.php.bak wp-config.php~ wp-config.old wp-config.txt wp-config.php.save wp-config.php.orig wp-config.bak install.php setup-config.php installer.php; do
code=$(curl -s -o /dev/null -w "%{http_code}" "https://example.com/$f")
echo "$code $f"
donecd /path/to/site
ls -la wp-config*
find . -maxdepth 2 \( -iname '*install*.php' -o -iname '*installer*' -o -iname '*.bak' -o -iname '*.old' -o -iname '*.orig' -o -iname '*~' \) -not -path './wp-content/plugins/*'How to fix it
Delete the exposed files
Remove every backup copy and leftover installer from the web root. Keep backups in a folder above the web root or in off-site storage, never in a public folder.
Assume the secrets leaked
If a file was reachable, even briefly, change the database password, then update DB_PASSWORD in the real wp-config.php. Replace the keys and salts with new ones from the official WordPress secret-key generator at api.wordpress.org/secret-key/1.1/salt/. This logs everyone out.
Check for signs of misuse
Review admin users, recently changed files and unknown plugins. Run a malware scan with your security plugin or host tools.
Block these file types at the server
Add a rule so backup-style names are never served, even if one appears again. See the server snippets below.
Fix the cause
Stop editors and deploy scripts writing copies into the web root. Remove installer files as the last step of any migration.
Delete files via SFTP or your host's file manager
Remove wp-config backups and installer files from the site root and subfolders. Migration plugins such as Duplicator leave installer files; check the plugin's cleanup option in its admin screen.
Move wp-config.php up one level if your host allows
WordPress will find wp-config.php one folder above the web root, which keeps it out of public reach.
Apache: add a deny rule to .htaccess
Use the FilesMatch rule shown below, then reload the page for a backup file name to confirm a 403.
Nginx: add a deny location
Add the location block shown below to your server config and reload Nginx with nginx -s reload.
<FilesMatch "(^wp-config.*\.(bak|old|orig|save|txt|swp|zip)$|~$|^(install|installer|setup-config)\.php$)">
Require all denied
</FilesMatch>
<Files wp-config.php>
Require all denied
</Files>location ~* /wp-config.*\.(bak|old|orig|save|txt|swp|zip)$ {
deny all;
}
location ~ ~$ {
deny all;
}
location = /wp-config.php {
deny all;
}How to confirm it's fixed
- Re-run the curl loop: every file name returns 403 or 404, not 200
- No wp-config backups or installer files remain when you list the server folders
- The site, login and your lead forms still work after the new rules
- The database password and secret keys have been changed if a file was ever reachable
- Admin users and recent file changes look normal
How to prevent it happening again
- Never save copies of config files in the web root; edit a copy elsewhere
- Store backups off-site or outside the public folder
- Delete installers and migration files as the last step of every move
- Keep the server deny rules in place permanently
- Turn off editor backup files (for example the tilde copies some editors create) on deploy machines
- Repeat the file-name check after every migration, redesign or host change
How FunnelGuard handles this
Questions people ask
Why is my wp-config.php.bak file a security risk?
A .bak file is not run as PHP, so the server sends its contents as plain text. Anyone who guesses the name can read your database password and secret keys. Delete it and change the exposed credentials.
How do I check if my wp-config backup is publicly accessible?
Open https://yoursite.com/wp-config.php.bak and similar names in a browser, or run a curl loop. A 200 response showing readable code means it is exposed. A 403 or 404 means it is not reachable.
What should I do if my wp-config backup was exposed?
Delete the file, then change your database password and update it in the real wp-config.php. Replace the keys and salts, review admin users and recent file changes, and run a malware scan.
Is wp-config.php itself safe to leave in the web root?
Usually yes, because the server runs it as PHP and shows nothing. It is safer to block direct requests to it or move it one folder above the web root. The danger is renamed copies the server serves as text.
Should I delete install.php after installing WordPress?
Core's wp-admin/install.php is part of WordPress and is safe on a finished site. Delete extra installer files left by migration plugins or manual builds, such as installer.php or setup scripts in the site root.
How do I block access to backup files in Apache or Nginx?
In Apache, add a FilesMatch rule with Require all denied for names like wp-config.php.bak. In Nginx, add a location block using deny all. Test afterwards to confirm a 403 response.
Does FunnelGuard detect exposed wp-config backups?
No. FunnelGuard does not check for this yet, though it could be added later. It monitors your funnels, tracking and lead delivery, so use the manual file check or a security scanner for this issue.