How to protect WordPress from common attacks on your site
Learn how to protect WordPress from common attacks: harden wp-config, block XML-RPC abuse, enforce 2FA, audit plugins, and secure off-site backups.

To protect WordPress from common web attacks on a business site, close the four entry points automated bots target first: keep WordPress core, themes, and plugins updated without pirated software, enforce two-factor authentication (2FA) on non-generic accounts, harden sensitive files like wp-config.php and xmlrpc.php, and maintain automated backups outside your hosting server. Because WordPress powers a massive share of the web, any newly launched installation begins receiving automated intrusion attempts within hours.
In most small and medium businesses, breaches do not stem from an exotic zero-day inside WordPress core, but from post-launch neglect: sites running twenty unmaintained plugins, accounts named admin with reused passwords, and backups stored inside the same compromised hosting directory. Applying layered defense dramatically lowers the likelihood of malware injection, SEO spam redirects, or search engine blacklisting.
Most frequent attack vectors against WordPress websites
Attackers rarely hand-pick small business sites one by one; they deploy automated scanners that sweep the internet for known WordPress fingerprints and exploit them in seconds. Understanding these primary vectors lets you focus effort where it counts.
- Outdated or pirated (nulled) plugins and themes: a single unpatched form builder, page builder, or backup plugin can expose remote code execution or SQL injection flaws. Pirated themes downloaded outside official repositories frequently ship with hidden backdoors from day one.
- Brute-force attacks against
wp-login.phpandxmlrpc.php: botnets test thousands of username and password pairs per minute, often abusing XML-RPC'ssystem.multicallmethod to bundle hundreds of login guesses into a single HTTP request. - Excessive permissions and an active built-in file editor: if an intruder gains administrator access while the PHP file editor remains enabled, they can alter the active theme's
functions.phpfile and plant a persistent webshell in seconds. - Missing security headers and weak TLS configuration: without strict HTTPS redirection and protective headers such as
Content-Security-PolicyorX-Content-Type-Options, sites remain exposed to session hijacking and cross-site scripting (XSS).
In WordPress, every inactive plugin left sitting on the server is still executable code on disk; if you are not actively using it, deactivate and delete it completely.
Essential WordPress hardening matrix for SMBs
Before installing heavy tools, map which technical safeguards protect each layer of your site. The matrix below organizes priority defenses by the threats they stop:
| Security layer | Recommended technical control | Attack neutralized |
|---|---|---|
| Identity and access | Remove default admin user, enforce TOTP 2FA, and rate-limit failed logins |
Brute force, credential stuffing, and password reuse takeovers |
| Code and extensions | Keep core, themes, and plugins patched; delete unused extensions; zero nulled code | Known vulnerability exploitation (RCE, SQLi, XSS) and pre-installed backdoors |
| Server configuration | Disable file editing (DISALLOW_FILE_EDIT), block xmlrpc.php, enforce 644/755 permissions |
Webshell injection, admin-panel escalation, and XML-RPC amplification |
| Network and transport | Valid TLS certificate, HSTS, HTTP security headers, and perimeter WAF | Traffic interception, clickjacking, and automated vulnerability probing |
| Operational continuity | Encrypted daily backups stored on external storage isolated from the web host | Total data loss after ransomware or full server compromise |
For a broader overview covering domains, corporate email, and server hygiene, pair these controls with our website security checklist for small businesses. You can also verify right away whether your server sends proper security headers and a valid certificate using our HTTP headers tester and SSL certificate analyzer.
Technical hardening in wp-config.php and .htaccess
Most automated exploits fail immediately when you enforce strict rules directly in WordPress configuration and the web server layer. The snippets below show proven hardening directives for wp-config.php and .htaccess (on Apache servers)—always create a backup before editing production files:
// --- Add to wp-config.php (above "That's all, stop editing!") ---
// Disable the built-in PHP theme and plugin code editor inside wp-admin
define( 'DISALLOW_FILE_EDIT', true );
// Force HTTPS across the admin dashboard and login flow
define( 'FORCE_SSL_ADMIN', true );
// Keep debug output disabled on production sites
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_DISPLAY', false );
<FilesMatch "^(wp-config\.php|xmlrpc\.php|readme\.html|license\.txt)$">
Require all denied
</FilesMatch>
# Prevent PHP execution inside the uploads directory
# (place inside wp-content/uploads/.htaccess)
<Files *.php>
Require all denied
</Files>
Alongside these directives, generate unique high-entropy passwords for your database, SFTP credentials, and every administrator account using our secure password generator, and verify domain DNS health with our DNS checker. These measures align directly with official WordPress.org Hardening WordPress documentation and the OWASP Top 10 web security standard.
Monthly maintenance routine and incident readiness
Securing WordPress is not a one-time setup task. A disciplined monthly routine takes under thirty minutes and prevents costly downtime when your website drives active sales or client inquiries:
- Verify backups before applying updates: confirm that off-site database and file backups completed without errors and test a clean restore in a staging environment at least once per quarter.
- Patch core, plugins, and PHP runtime: test security updates in staging first if you operate an online store (WooCommerce), and keep PHP on an actively supported security branch.
- Audit user accounts and roles: remove accounts belonging to former agencies, designers, or writers and verify that no subscriber or editor role was silently escalated to administrator.
- Inspect access logs and file integrity alerts: look for abnormal spikes of
POSTrequests targetingwp-login.php, unexpected new files insidewp-content/uploads/, or suspicious outbound redirects.
If your website already shows warning signs—such as spam pages indexed on Google, sudden slowdowns, or unfamiliar admin accounts—follow our guide on how to tell if your website was hacked. To understand what a thorough technical review covers before scaling campaigns or launching new features, read what a web security audit checks.
Frequently asked questions
What is the number one cause of hacked WordPress websites in small businesses?
The leading causes are unpatched plugins or themes, pirated (nulled) templates bundled with hidden backdoors, and weak administrator passwords without mandatory two-factor authentication (2FA).
Should I disable XML-RPC on my WordPress installation?
Yes, in most setups you should block xmlrpc.php at the web server or firewall level. Only keep it enabled if you rely on a specific legacy client or external integration that requires XML-RPC.
Is a WordPress security plugin enough to protect my site by itself?
No. A security plugin provides useful monitoring and basic filtering, but it cannot replace timely WordPress and PHP updates, disabling PHP file editing, enforcing 2FA, applying proper server permissions, and maintaining off-site backups.
How often should a business WordPress website be backed up?
For websites with active lead forms, regular publishing, or e-commerce transactions, run daily database backups and weekly file backups to external storage separate from your hosting provider, and periodically verify restore integrity.
Check your website's live security posture right now with our HTTP headers tester and SSL certificate analyzer. If you need a comprehensive review of your WordPress installation or web stack, explore our TecnoCrypter security products.


