Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/moizxox/ip-blocker-plugin/archive/refs/heads/main.zipNo built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
A lightweight WordPress plugin to block visitors by IP/CIDR and by country (via CDN/host headers). Optionally writes Apache .htaccess IP rules for server-level blocking.
Features
- Block individual IPs or CIDR ranges (IPv4/IPv6)
- Block by country using headers like
CF-IPCountry,X-AppEngine-Country - Optional Apache
.htaccessIP blocking (no country support) for faster server-level deny - Minimal UI, simple code, fast and lightweight
How It Works
- PHP mode: Early hook inspects client IP and country headers, returns 403 for matches
- .htaccess mode: Writes
Require not ip/Deny fromrules between markers to.htaccess
Requirements
- For country blocking, your CDN/host must set a country header (e.g., Cloudflare
CF-IPCountry) - For
.htaccessmode, your site must be on Apache withmod_authz_core(or legacy directives)
Installation
- Copy the
wp-ip-blockerfolder intowp-content/plugins/ - Activate “WP IP Blocker” in WordPress → Plugins
- Go to Settings → IP Blocker to configure
Settings
- Enable Blocking: Master switch
- Mode:
PHP(IP + country) orApache .htaccess(IP only) - Blocked IPs/CIDRs: One per line, supports IPv4/IPv6 and CIDR
- Blocked Countries: Select multiple. You can also add extra ISO codes manually
- Bypass Logged-in Admins: Avoids locking yourself out while testing
Uninstall
Running uninstall deletes plugin options and removes .htaccess rules created by this plugin.
Notes
- This plugin avoids heavy DB queries and does not affect site performance under normal conditions
- Works with proxies/CDNs by honoring
X-Forwarded-For,X-Real-IP, andCF-Connecting-IP