创建一个处理多个目的地的重定向页面php?

问题描述 投票:-1回答:1

我有一个大约50页的网站,每个网站都会将访问者发送到不同的外部网址,目前直接链接到外部域。

我正在重建网站,并希望让访问者首先通过内部重定向页面。

而不是构建50个不同的重定向页面,如何创建一个可以处理所有这50个不同目的地的重定向页面?

我想我可以将链接转换成

http://example.com/redirect.php?destination=[1/2/3/4/.../50]

但是我如何在redirect.php上定义(以最简单的方式), 每个目标号码的匹配外部URL?

最好用一些简单的.text文件,比如

1 http://external-1.com/
2 http://external-2.com/
.
.
50 http://external-50.com/
php redirect
1个回答
0
投票

请试试这个

<?php
$destinations = array(
1=> 'http://urlone',
2=> 'http://urltwo',
3=> 'http://urlthree',
);
$destination = $_GET['destination'];
if(in_array($destination, $destinations)){
    header("location:".$destinations[$destination]);
}
?>
© www.soinside.com 2019 - 2024. All rights reserved.