A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.cloudflare.com/rules/snippets/examples/country-code-redirect/ below:

Country code redirect · Cloudflare Rules docs

* A map of the URLs to redirect to

* @param {Object} countryMap

// Replace the country codes and target URLs with ones that apply to your case.

US: "https://example.com/us",

EU: "https://example.com/eu",

// Use the cf object to obtain the country of the request

// more on the cf object: https://developers.cloudflare.com/workers/runtime-apis/request#incomingrequestcfproperties

const country = request.cf.country;

// If country is not null and is defined in the country map above, redirect.

if (country != null && country in countryMap) {

const url = countryMap[country];

// Remove this logging statement from your final output.

`Based on ${country}-based request, your user would go to ${url}.`,

return Response.redirect(url);

// If request country not in map, return another page.

return fetch("https://example.com", request);


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4