Forked from tjhole/WORDPRESS: Redirect based on location using Cloudflare
Created
January 1, 2018 16:12
-
-
Save ghhv/54089f393759253e376133f4cdf852d3 to your computer and use it in GitHub Desktop.
WORDPRESS: Redirect based on location using Cloudflare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Geo Redirect using Cloudflare | |
$activepage = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; | |
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; | |
$page_from = "www.domain.tld/"; | |
$page_to = "www.newdomain.tld/"; | |
?> | |
<!-- Country Code : <?php echo $country_code; ?> --> | |
<!-- Active URL : <?php echo $activepage; ?> --> | |
<?php | |
if($activepage == $page_from && $country_code=="US") { | |
Header("Location: $page_to"); | |
die(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment