📜  php preg_match html 跨域 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:06.335000             🧑  作者: Mango

代码示例1
$origin = $_SERVER['HTTP_ORIGIN'];
$allowed_domains = [
    'http://mysite1.com',
    'https://www.mysite2.com',
    'http://www.mysite2.com',
];

if (in_array($origin, $allowed_domains)) {
    header('Access-Control-Allow-Origin: ' . $origin);
}