---
title: Methods to protect your WordPress site from breaches
canonical: https://wpsecurityninja.com/methods-protect-site-from-breaches/
---
WordPress is a common target because it is common. Most breaches still come from outdated plugins, weak or shared admin passwords, and leftover access, not from exotic zero-days.

This post covers defenses that change real risk. For the longer playbook, use the [WordPress security hardening guide](https://wpsecurityninja.com/wordpress-security-hardening-guide/) and the [login security guide](https://wpsecurityninja.com/wordpress-login-security-complete-guide/).

![WordPress security](https://wpsecurityninja.com/media/2019/10/fikret-tozak-Zk-Ydz2IAs-unsplash-3-1024x683.webp)

## Keep WordPress, themes, and plugins updated

Unpatched plugins are the usual entry point. Update on a schedule. Delete what you do not use, including deactivated leftovers.

Scan installed software for known issues with a [vulnerability scanner](https://wpsecurityninja.com/vulnerabilities/). Small sites get attacked too: [why “insignificant” sites get hit](https://wpsecurityninja.com/why-is-insignificant-small-site-attacked-by-hackers/).

![Updates](https://wpsecurityninja.com/media/2019/10/update-4223736_1920.jpg)

## Strong logins and two-factor authentication

Protect wp-admin with unique passwords from a password manager, then add [two-factor authentication](https://wpsecurityninja.com/two-factor-authentication-2fa/) for every administrator (and anyone who can install plugins).

Limit failed logins and review who has the Administrator role. Details: [login security](https://wpsecurityninja.com/wordpress-login-security-complete-guide/) and [user roles](https://wpsecurityninja.com/wordpress-user-roles/).

## Restrict admin access by IP (when your IP is stable)

If you always manage the site from a fixed office IP, you can deny everyone else at the web server. This fails on home broadband with a changing IP, mobile networks, and travel. Prefer [login protection](https://wpsecurityninja.com/login-protection/) and 2FA when your address moves.

Apache 2.2-style example in the site root `.htaccess` (replace with your real IP). Put this outside any WordPress rewrite block your host manages, or ask the host to apply an equivalent rule:

```apache
<Files wp-login.php>
	Order Deny,Allow
	Deny from all
	Allow from 203.0.113.10
</Files>
```

Apache 2.4 prefers `Require`:

```apache
<Files wp-login.php>
	Require ip 203.0.113.10
</Files>
```

Locking down the whole `wp-admin` directory the same way can break AJAX and plugin admin calls from other IPs. Test on staging first. A [Cloud Firewall](https://wpsecurityninja.com/cloud-firewall/) or host WAF with IP allowlists is often easier to reverse than a broken `.htaccess`.

## Force HTTPS for the admin area

Use HTTPS site-wide (host or Let’s Encrypt). Then force admin over SSL in `wp-config.php`, above the line that loads `wp-settings.php`:

```php
define( 'FORCE_SSL_ADMIN', true );
```

SSL alone does not stop plugin exploits. It stops cleartext admin sessions on hostile networks. Basics: [SSL certificates](https://wpsecurityninja.com/basic-guide-to-understanding-ssl-certificates/).

## Disable TRACE and TRACK

Some Apache setups still allow TRACE/TRACK, which historically helped cross-site tracing attacks. In root `.htaccess`:

```apache
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
```

If the host already blocks these methods at the server level, you do not need a duplicate rule.

## Reduce username discovery from author archives

Default author archives can leak login names (`?author=1`). That does not replace a strong password, but it removes an easy first step for [brute-force](https://wpsecurityninja.com/dictionary/brute-force/) tools.

In a child theme’s `functions.php` (never edit a parent theme you will overwrite):

```php
add_action( 'template_redirect', 'sn_redirect_author_archives' );
function sn_redirect_author_archives() {
	if ( is_author() ) {
		wp_safe_redirect( home_url( '/' ), 301 );
		exit;
	}
}
```

Renaming the login URL is optional convenience, not a substitute for 2FA. See [login security](https://wpsecurityninja.com/wordpress-login-security-complete-guide/).

![Login](https://wpsecurityninja.com/media/2019/10/registration-3938434_1920-1.jpg)

## Trim noisy header meta (optional cleanup)

Removing generator tags and old RSD/WLW links does not stop a skilled attacker. It is fine as housekeeping. Broken snippets are worse than leaving the tags alone.

In a child theme `functions.php`:

```php
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
```

Hiding the WordPress version in HTML does not replace updates. Attackers probe plugins and known endpoints regardless of the meta generator line.

## Choose a host that takes security seriously

A solid host gives you TLS, malware scanning or isolation options, and backups you can actually restore. Pair hosting with application hardening: [security best practices](https://wpsecurityninja.com/wordpress-security-best-practices/), [firewall plugins guide](https://wpsecurityninja.com/wordpress-firewall-plugins-guide/), and [offsite backups](https://wpsecurityninja.com/wordpress-backup-tips-backing-up-your-site-for-protection/).

![SSL certificate](https://wpsecurityninja.com/media/2019/10/https-3344700_1920.jpg)

## Defenses that matter more than theater

Priority order for most sites:

1. Unique passwords and 2FA on admins  
2. Updates and delete unused plugins  
3. Offsite backups you have restored once  
4. Firewall / login rate limits ([Cloud Firewall](https://wpsecurityninja.com/cloud-firewall/))  
5. Monitoring for mystery files and new admins  

You will not make a public site unhackable. You can make opportunistic attacks noisy, expensive, and recoverable. Full checklist: [WordPress security hardening guide](https://wpsecurityninja.com/wordpress-security-hardening-guide/).
