-
Notifications
You must be signed in to change notification settings - Fork 15
/
geoip-target-redirect.html
50 lines (47 loc) · 2.05 KB
/
geoip-target-redirect.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<script>
/*!
* GeoIP Target Redirector
* Project: https://github.com/OpenAff/geoip-target-filter
*
* ---------------------------------------------------------------------
* A small snippet for geo-target redirection using GeoIP API.
* Add your targeted country's "ISO 3166-1 - Alpha-2" code and
* redirect URL to the "target" array object.
* ---------------------------------------------------------------------
* Example:
* target.All = "http://others.tld";
* target.US = "http://domain.tld";
*
* The above example will redirect all the US visitors to the given URL.
* And any non-targeted visitors to "All" URL.
* ---------------------------------------------------------------------
* Country Codes can be found @( Wikipedia - http://bit.ly/nWBMYz )
* See Column: "Alpha-2 Code"
* ---------------------------------------------------------------------
*/
var target = []; // Create a new target Array.
// Example Codes:
target.All = "https://domain.com/"; // Redirects Non-targeted / all other visitors to this URL.
target.US = "https://domain.us/"; // Redirects US Visitors to this URL.
target.GB = "https://domain.uk/"; // Redirects UK Visitors to this URL.
target.CA = "https://domain.ca/"; // Redirects Canadian Visitors to this URL.
// ------------------------------------------------------
// DON'T EDIT THE BELOW CODE UNLESS REQUIRED
// ------------------------------------------------------
/**
* If a valid country code matches the targets list, then it redirects to that particular link.
* Otherwise redirects to "All" target URL.
*/
function geoip(g){window.top.location.href=target[g.country]||target.All}
</script>
<script src="https://get.geojs.io/v1/ip/country.js?callback=geoip"></script>
</head>
<body>
<p>Please wait...</p>
</body>
</html>