Automatically redirect visitors based on location
Geo redirects automatically send visitors to a different URL based on their geographic location. This is the most common form of geo-targeting, used by businesses that have separate websites or landing pages for different countries or regions.
For example, you might redirect visitors from Germany to example.de and visitors from France to example.fr, while everyone else stays on example.com.
The geoswap.js script loads on your page and sends the visitor's request to the GeoSwap edge network.
Cloudflare Workers determine the visitor's country, region, and city using edge-level geolocation. No third-party API calls are needed.
The Worker checks your redirect rules (stored in Redis for speed) and determines whether a redirect should happen. Rules are evaluated in priority order.
If a rule matches, the geoswap.js script performs the redirect. The visitor sees a near-instant navigation to the correct URL.
Add the GeoSwap script to your website. See the Installation Guide for platform-specific instructions.
<script src="https://cdn.geoswap.co/geoswap.js" data-account="YOUR_ACCOUNT_ID" defer></script>In the GeoSwap dashboard, navigate to Redirects and click New Geo Redirect.
The page where the redirect should trigger. This can be a specific URL or a URL pattern with wildcards (e.g., example.com/*).
Select one or more countries. Visitors from these countries will be redirected. Use explicit matching (select the countries you want to redirect) rather than exclusion rules for best SEO safety.
The URL where matched visitors will be sent. Must be a full URL including https://.
Googlebot is never redirected
When you use explicit country matching (e.g., "redirect visitors from Germany"), Googlebot does not match any country and sees your original page. This is by design. See the SEO Guide for details.
Avoid "not equal to" rules
Rules like "redirect everyone NOT in the US" will match Googlebot (whose IP resolves to no identifiable country), causing it to be redirected away from your page. Always use explicit country targeting instead. GeoSwap will warn you in the dashboard if you create a rule that could affect search engine crawlers.
When you create geo redirects between language or country variants of your site, GeoSwap automatically generates the correct hreflang tags. These tags tell search engines about your alternate-language pages, preventing duplicate content issues and ensuring the right version appears in local search results.
<!-- Auto-generated by GeoSwap -->
<link rel="alternate" hreflang="en" href="https://example.com/" />
<link rel="alternate" hreflang="de" href="https://example.de/" />
<link rel="alternate" hreflang="fr" href="https://example.fr/" />
<link rel="alternate" hreflang="x-default" href="https://example.com/" />You can also use the Hreflang Generator tool in the dashboard to preview and customize the output.
You do not need a VPN to test geo redirects. GeoSwap provides two ways to simulate a different location:
Each redirect rule has a "Test" button that lets you simulate any country and see exactly what would happen.
Use the Rule Simulator tool in your dashboard to test geo-targeting from any country. Pick a country, device, and page to see exactly which rule fires — no VPN needed.
Use explicit country matching (select specific countries), not exclusion rules.
Start with 302 (temporary) redirects during testing, then switch to 301 once confirmed.
Enable "once per session" to prevent redirect loops when visitors use the back button.
Use pass-through mode when redirecting between domain variants (e.g., example.com to example.de) to preserve the URL path.
Add labels to organize rules when you have many redirects (e.g., by region or campaign).
Review the SEO Check tool in the dashboard after creating rules to catch potential issues.
Manage redirects at scale with CSV import and edge execution.