$value) { $headersLog .= "$header: $value\n"; } // API 返回日志信息 $apiResponseLog = "调用接口结果: " . ($country == 'China' ? "中国访问" : ($country == 'United States' ? "美国访问" : "其他国家访问")) . "\n"; // Write headers, country info, and API result to the log file writeLog($headersLog); writeLog($apiResponseLog); // 301 重定向到不同域名 if ($country == "China") { writeLog("重定向到: /cn/products\n"); header('HTTP/1.1 301 Moved Permanently'); header('Location: /cn/products'); } elseif ($country == "United States") { writeLog("重定向到: /en/products\n"); header('HTTP/1.1 301 Moved Permanently'); header('Location: /en/products'); } else { writeLog("重定向到: /en/products (默认英文)\n"); header('HTTP/1.1 301 Moved Permanently'); header('Location: /en/products'); // Default to English } exit(); // Stop the script after redirecting ?>