Web Security
WordPress Security Hardening: What We Check on Hosted Sites
Updated 7 November 2026·10 min read·MeraSEO, Mumbai
Most WordPress security lists tell you to install a security plugin, update everything and use strong passwords. That is fine, and our website maintenance checklist already covers the basics. This post goes where that list stops: the files sitting in your hosting account, the permission numbers, the server rules that block them, and a monthly routine that proves it all still works.
On sites we host (around 70 WordPress sites), we keep core current, lock wp-config.php to 600 and block web access to config files, logs, dumps and backups at the server. When we audit a hosting account, a common risk is not a clever exploit. It is a forgotten database dump or backup archive left inside the public web folder, where anyone who guesses the file name can download it. Everything below is about finding and closing that kind of gap. Shell commands assume SSH access; each step also has a File Manager equivalent.
Your web root is usually called public_html (on some hosts it is htdocs or www). Anything inside it can be requested over HTTP if the server is willing to serve it. Look for files that should never be there:
From SSH, run this in your account’s home directory (adjust the path if your folder is named differently):
find ~/public_html -type f \( -iname "*.sql" -o -iname "*.sql.gz" -o -iname "*.zip" -o -iname "*.tar" -o -iname "*.tar.gz" -o -iname "*.tgz" -o -iname "*.7z" -o -iname "*.bak" -o -iname "*.old" -o -iname "*.orig" -o -iname "*~" -o -iname "*.log" -o -name "error_log" -o -name ".env" -o -iname "wp-config*" -o -iname "phpinfo.php" -o -iname "info.php" \) -printf "%s %p\n" | sort -rn | head -100
There is deliberately no size filter: a .env file or a copy of wp-config.php is tiny and still exposes passwords. Expect to see plugin .zip files and your live wp-config.php in the list; you are looking for the extra copies, such as wp-config.php.bak or wp-config-old.php, and dumps with dates in their names.
Without SSH, use your host’s File Manager search with each extension, and sort the results by size. Do not forget subfolders: plugin backup folders, old site copies in a /old/ directory and a forgotten /staging/ folder are the usual places.
A file in the web root is only a risk if the server serves it. Test each suspicious file from your own computer:
curl -I https://example.com/path/to/backup.zip
A 200 response with a Content-Length means anyone can download it. A 403 or 404 means something is already blocking it. Note that a plugin’s own backup folder may be protected by a rule you cannot see, so test rather than assume.
Create a folder above the web root, for example ~/private_backups, and move the files there. Your home directory sits outside public_html, so the web server will not serve its contents. If you only have a File Manager, drag the files to the folder one level up. Do not just rename them; a renamed .zip is still downloadable. If a dump contains customer data and you think it was reachable, treat that as an incident: check the access logs for requests to that file name, change the database password, admin passwords and the salts in wp-config.php, and consider a malware and security check. If personal data may have leaked, take advice on your reporting duties under India’s CERT-In directions and the DPDP Act.
The right numbers depend on which user PHP runs as. If PHP runs as your own account (common with LiteSpeed and suPHP-style setups), a file that only PHP reads, such as wp-config.php, does not need to be readable by anyone else. Images, CSS and JavaScript still need 644, because the web server itself sends them. If PHP runs as a shared web user, it needs group access.
| Item | PHP runs as your account | PHP runs as a shared web user | Notes |
|---|---|---|---|
| wp-config.php | 600 | 640 (or 440) | Holds database credentials, so make it the tightest file |
| Other PHP and content files | 644 | 644 | Standard |
| Folders | 755 | 755 | Never 777 |
| wp-content/uploads | 755, files 644 | 755 or 775 | Needs write access, but must not execute PHP |
| .htaccess | 644 | 644 | Make sure only you can edit it |
If the site breaks after you tighten a permission, go back one step (600 to 640). Do not use 777 as a fix. If you are unsure which model your host uses, ask support, or check the owner of files created by WordPress uploads: if it matches your account name, PHP runs as you.
On Apache and LiteSpeed, rules in the .htaccess file in your web root can refuse requests for sensitive file types. Back up the file first.
# Block dumps, backups, logs, editor copies and environment files
<FilesMatch "(?i)(\.(sql|sql\.gz|bak|old|orig|save|swp|log|env|ini|dump)|~)$">
Require all denied
</FilesMatch>
# Block the configuration file and the PHP error log
<FilesMatch "^(wp-config\.php|error_log)$">
Require all denied
</FilesMatch>
# No directory listings
Options -Indexes
If the whole site returns a 500 error after you save, your host may not allow the Options line in .htaccess; remove it and ask support to switch off directory listings instead. “Require all denied” is Apache 2.4 syntax, which LiteSpeed also reads. If you are on a server that does not use .htaccess, such as plain Nginx, ask your host to add equivalent location rules.
Archives (.zip, .tar.gz) are deliberately not in the list above, because many sites legitimately offer downloads. The better fix for archives is to keep them out of the web root (section 5), and block specific folders when needed.
After saving, request each sensitive URL and confirm a 403 or 404:
curl -I https://example.com/wp-config.php
curl -I https://example.com/old-dump.sql
curl -I https://example.com/wp-content/uploads/
A 200 on a dump or backup file means the rule did not apply. One quirk: without the rule, wp-config.php itself usually returns 200 with an empty page, because PHP runs the file and prints nothing. That is not a leak by itself; the dangerous case is a copy such as wp-config.php.bak, which the server sends as plain text. So test a dummy file too: upload an empty test.sql, confirm it returns 403, then delete it. Use a cache-busting query string when you test if you sit behind a CDN, since it can serve a cached answer for a few minutes. Also confirm the normal site still loads, including the admin area.
define('DISALLOW_FILE_EDIT', true); to wp-config.php. It removes the theme and plugin editors, so a stolen admin login cannot rewrite code from the dashboard.wp user list --role=administrator. Avoid a username like “admin” and use unique passwords with two-factor sign-in.\.(php|phtml|phar)$ with Require all denied, then upload a harmless test.php there and confirm it returns 403.For the full reference, WordPress documents hardening in the advanced administration handbook.
A backup you can download from the browser is a backup everyone can download. Set your backup plugin’s storage location to a folder outside public_html, or better, to remote storage such as a cloud bucket. Check that old backup archives are removed on a schedule so they do not pile up. Keep one copy that is not on the same server as the site; a backup that dies with the server is not a backup.
If you want this done for you, it is part of our WordPress maintenance and support. For deeper testing against the common web attack classes, see website penetration testing.
Leaving old database dumps and backup archives inside the public web folder. Anyone who guesses the file name can download them, and they often contain customer data and credentials. Search your hosting account for .sql, .zip and .tar.gz files, test whether the URLs download, and move them to a folder above the web root.
Use 600 where PHP runs as your own account, which makes the file readable only by you. On setups where PHP runs as a shared web user, 640 or 440 is usual. If the site breaks, step back one level. Never use 777 on any WordPress file or folder.
Upload an empty test file such as test.sql, then request it from outside with curl -I. A 403 means the rule works; a 200 means it does not. Do the same for a copy like wp-config.php.bak, then delete the test files. Use a cache-busting query string if you use a CDN, and check the normal site still loads.
If you do not use Jetpack or a tool that needs it, yes. XML-RPC lets attackers try many password guesses in one request. Block xmlrpc.php with a server rule or firewall, then confirm your publishing and integrations still work. If something stops, allow only the specific tool you need.
We check for exposed files, permissions and admin accounts, and fix what we find.
See WordPress maintenance and support →WhatsApp us