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 checked top to bottom, and the first match wins.
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>window.geoswap=window.geoswap||{q:[],track:function(){this.q.push(arguments)}};</script>
<script src="https://cdn.geoswap.co/geoswap.js" data-project="YOUR_PROJECT_ID" defer></script>In the GeoSwap dashboard, navigate to Redirects and click New Geo Redirect.
The pages where the redirect can fire: all pages, a list of exact URLs, or a URL pattern. To run only on one of your domains, use a pattern like ^https?://(www\.)?example\.com/. See Page Targeting for more patterns.
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.
Each rule pairs a segment with a destination, and you choose how that destination works:
https://example.de/welcome.https://example.in, a visitor on example.com/products/lamp?color=red lands on example.in/products/lamp?color=red. Add a path to put them under a folder: https://example.in/en sends them to example.in/en/products/lamp.You can mix both in one redirect, for example India on Swap domain and the UK on a Specific URL. Rules are checked top to bottom, and the first one that matches the visitor wins.
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 a redirect sends countries to language or country versions of a page, GeoSwap works out the matching hreflang tags for you. These tags tell search engines which version belongs to which audience, so the right one shows up in local results. Copy them from Geo Tools → Hreflang in the dashboard and add them to the <head> of your page. GeoSwap doesn't insert them for you.
Tags are generated for redirects set to Specific URLs whose rules target countries. Swap domain rules are skipped for now, because each page would need its own alternate URL.
<!-- Generated by GeoSwap (Geo Tools → Hreflang) -->
<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.
Test with Simulate Rules or a preview link before you go live, so you see exactly where each country lands.
Moving visitors between your own domains (example.com to example.de)? Use Swap domain so they land on the same page instead of the homepage.
Running the same script on several sites? Target the rule with a full-address pattern so it only fires on the site you mean.
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.