Overview

The Block Specific Countries feature in AdminEase allows you to automatically block visitors from specific countries by generating .htaccess rules that deny access based on the visitor’s country code. This feature works best with Cloudflare and it should be active on for your domain, GeoIP is used as fallback incase Cloudflare is inactive.

Prerequisites

Don’t have Cloudflare? Sign up for free at cloudflare.com

Cloudflare Setup

  1. Create a Cloudflare account at cloudflare.com
  2. Add your domain to Cloudflare
  3. Update your DNS nameservers to point to Cloudflare
  4. Enable proxy mode (orange cloud) for your domain records
  5. Wait for activation – Cloudflare will automatically add country headers to requests

How It Works

Country Detection

  • Uses Cloudflare’s CF-IPCountry header to identify visitor locations
  • Works automatically once Cloudflare is properly configured
  • No additional setup required on your server

Blocking Mechanism

  • Generates Apache .htaccess rules using mod_rewrite
  • Blocks happen at the server level before WordPress loads
  • Returns HTTP 403 Forbidden error to blocked visitors
  • Rules are added at the top of .htaccess for optimal performance

Using the Feature

Step 1: Access AdminEase Settings

  1. Go to your WordPress admin dashboard
  2. Navigate to AdminEase in the main menu
  3. Click on the Security tab

Step 2: Configure Country Blocking

  1. Find the Block Specific Countries section
  2. Toggle the feature ON
  3. Use the country selection field to choose which countries you want to block by selecting them from the dropdown list

Step 3: Save Settings

  1. Click Save Settings
  2. The feature will automatically generate and add the blocking rules to your .htaccess file
  3. Changes take effect immediately

Generated .htaccess Rules

When you save settings, AdminEase automatically generates rules like this:

# ADMINEASE_BLOCK_SPECIFIC_COUNTRIES START
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Cloudflare compatibility
    RewriteCond %{HTTP:CF-IPCountry} ^CN$ [OR]
    RewriteCond %{HTTP:CF-IPCountry} ^RU$ [OR]
    RewriteCond %{HTTP:CF-IPCountry} ^KP$
    RewriteRule .* - [F]
</IfModule>
# ADMINEASE_BLOCK_SPECIFIC_COUNTRIES END

Performance Benefits

Server-Level Blocking

  • Efficient Processing: Uses Apache’s mod_rewrite for fast blocking
  • No PHP Overhead: Blocks happen before WordPress loads
  • Reduced Server Load: Blocked requests consume minimal resources

Cloudflare Integration

  • Edge Network: Leverages Cloudflare’s global infrastructure
  • Accurate Detection: Uses Cloudflare’s extensive IP database
  • Automatic Updates: Country data is maintained by Cloudflare

Troubleshooting

Feature Not Working?

Check Cloudflare Status:

  1. Verify your domain is active on Cloudflare
  2. Ensure proxy mode (orange cloud) is enabled
  3. Check that Cloudflare is properly routing traffic

Verify Country Detection:
You can test if Cloudflare headers are present by adding this temporary code to your theme’s functions.php:

add_action('wp_head', function() {
    if (current_user_can('manage_options')) {
        echo '<!-- CF Country: ' . ($_SERVER['HTTP_CF_IPCOUNTRY'] ?? 'Not detected') . ' -->';
    }
});

Then visit any page while you are logged in as an admin.

Common Issues:

  • Cloudflare not active: The most common cause – ensure Cloudflare is properly configured
  • Direct IP access: Visitors accessing your server’s direct IP bypass Cloudflare
  • Mixed configuration: Some DNS records not proxied through Cloudflare

Testing the Block

Safe Testing Method:

  1. Use a VPN to simulate traffic from a blocked country
  2. Try accessing your website
  3. You should see an HTTP 403 Forbidden error
  4. Switch VPN to an allowed country – site should load normally

Important: Always test with a VPN or proxy, never block your own actual country!

Best Practices

Security Considerations

  • Admin Access: Ensure you never block countries from which you need admin access
  • False Positives: Be aware that VPN users may appear to be from blocked countries
  • Legal Compliance: Ensure country blocking complies with your local laws and regulations

Performance Tips

  • Limit Countries: Only block countries that are genuinely problematic for your site
  • Monitor Logs: Check your server logs to ensure legitimate traffic isn’t being blocked
  • Regular Review: Periodically review your blocked country list

Maintenance

  • Backup First: AdminEase creates automatic backups, but manual backups are recommended
  • Test Changes: Always test country blocking rules after making changes
  • Monitor Traffic: Keep an eye on your analytics to ensure desired traffic isn’t affected

Removing Country Blocks

To Disable Feature:

  1. Go to AdminEase → Security
  2. Toggle Block Specific Countries to OFF
  3. Click Save Settings
  4. The blocking rules will be automatically removed from your .htaccess file

To Modify Blocked Countries:

  1. Simply update the country selection in the dropdown field
  2. Save settings
  3. Rules will be automatically updated

Support

If you encounter issues with the country blocking feature:

  1. Verify Cloudflare Setup: Ensure Cloudflare is properly configured and active
  2. Check Server Compatibility: Ensure your server supports .htaccess and mod_rewrite
  3. Review Error Logs: Check your server’s error logs for any related issues
  4. Contact Support: Reach out to AdminEase support with specific error messages by opening a support ticket.

For additional help, contact our support team.


This feature works best with Cloudflare.