IP blocking allows you to deny or allow access to your website from specific IP addresses or ranges. This is useful for preventing spam, blocking malicious visitors, or restricting access to specific users.
For more advanced control, you can edit your .htaccess file:
# Block a single IP address
Deny from 192.168.1.1
# Block multiple IP addresses
Deny from 192.168.1.1
Deny from 192.168.1.2
# Block an IP range
Deny from 192.168.1.0/24To create an allowlist (whitelist) that only allows specific IP addresses:
Order Deny,Allow
Deny from all
Allow from 192.168.1.1
Allow from 192.168.1.2You can block entire IP ranges using CIDR notation:
/24blocks 256 addresses (e.g., 192.168.1.0/24)/16blocks 65,536 addresses (e.g., 192.168.0.0/16)/8blocks 16,777,216 addresses (e.g., 192.0.0.0/8)Prevent automated spam from known bot IPs
Block traffic from specific countries (using IP ranges)
Block IPs showing suspicious behavior
Allow only your office IP to access staging sites
You can find IP addresses in several places:
To unblock an IP address:
Or remove the corresponding line from your .htaccess file.
Contact support to have your IP unblocked
Check .htaccess syntax and file permissions
Make sure you didn't block Cloudflare IPs if using CDN