<?php

$config = require "config.php";


// 获取用户选择域名
$domain = $_GET['domain'] ?? $config['default'];


// 判断是否合法
if(!in_array($domain,$config['domains'])){

    $domain=$config['default'];

}


// 当前访问路径

$path = $_SERVER['REQUEST_URI'];


// 防止循环

if(strpos($path,"domain=")!==false){

    $path=parse_url($path,PHP_URL_PATH);

}


// 生成下载地址

$url="https://".$domain.$path;


// 跳转

header("Location: ".$url, true, 302);

exit;