<?php
$pageVersion = !empty($_GET["intgrtn_pageVersion"]) ? $_GET["intgrtn_pageVersion"] : null;

$availablePageVersions = array("v1", "v2", "v3");
if ($pageVersion) {
    if (in_array($pageVersion, $availablePageVersions)) {
        header('Location: ' . $pageVersion . "?" . $_SERVER['QUERY_STRING']);
    } else if (!empty($_SERVER['QUERY_STRING'])) {
        header('Location: v1/' . $_SERVER['QUERY_STRING']);
    } else {
        header('Location: v1/');
    }
} else if (!empty($_SERVER['QUERY_STRING'])) {
    header('Location: v1/?' . $_SERVER['QUERY_STRING']);
} else {
    header('Location: v1/');
}
