To comply with regional tax guidelines or show tailored landing content, many global store owners enable the core WooCommerce Geolocation lookup feature. However, a highly disruptive bug frequently surfaces where international visitors get stuck in an infinite page-refresh redirect loop. The browser screen blinks continuously, trying to load the homepage until it ultimately crashes with a "Too many redirects" browser error string.

This bug is caused by a structural conflict between your web host's page caching layer and the WooCommerce integration with the MaxMind GeoIP database. When "Geolocate (with page caching support)" is active, WooCommerce appends a query parameter (?v=XXXX) to the URL string to bypass static caches for unique countries. If your theme utilizes a custom geolocation routing wrapper, or if your .htaccess/Nginx files aggressively strip out unknown query arrays to sanitize URLs, a conflict loop triggers. WooCommerce sees no geo-tag, initiates a redirect to apply it, the server scrubs it away, and WooCommerce redirects the user again, infinitely.

The Solution

Breaking the country redirect loop requires stabilizing your query parameter handling maps and synchronizing your caching rules.

  1. Whitelist the Geo-Query Parameter: Open your performance/caching layer settings (such as Cloudflare or Varnish rules). Ensure that the v parameter used by WooCommerce is explicitly whitelisted and excluded from global URL sanitization algorithms.

  2. Fallback to Standard Geolocation: If your server infrastructure cannot handle cache-busting query loops gracefully, navigate to WooCommerce > Settings > General. Change the Default customer location from "Geolocate (with page caching support)" to standard Geolocate.

  3. Use Server-Level GeoIP Modules: Avoid using PHP-level lookups for routing logic. Ask your hosting provider to enable the native Nginx GeoIP2 module. This allows you to safely grab the customer's two-letter country code directly from the server header variables via code snippets:

PHP
 
add_filter('woocommerce_geolocate_user_location', 'server_level_geoip_fallback', 10, 2);
function server_level_geoip_fallback($default, $geoip) {
    if (isset($_SERVER['HTTP_X_COUNTRY_CODE'])) {
        return array('country' => $_SERVER['HTTP_X_COUNTRY_CODE'], 'state' => '');
    }
    return $default;
}