Skip to content

Instantly share code, notes, and snippets.

@localhots
Created May 20, 2014 12:53
Show Gist options
  • Save localhots/49c4734e0b80935ae179 to your computer and use it in GitHub Desktop.
Save localhots/49c4734e0b80935ae179 to your computer and use it in GitHub Desktop.
<?php
$config_file = "default.json";
$config = json_decode(file_get_contents($config_file));
$host = $config["default_host"];
$uri = $_SERVER["QUERY_STRING"];
if ($config["ab_enabled"]) {
if (in_array($_COOKIE["ab"], $config["ab_hosts"])) {
$host = $_COOKIE["ab"];
} else {
$host = array_rand($config["ab_hosts"]);
setcookie("ab", $host, 86400);
}
}
header("Location: http://$host$uri");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment