gpt4 book ai didi

php - 将一个页面重定向到另一个页面 5 秒,然后再次重定向

转载 作者:可可西里 更新时间:2023-11-01 12:52:51 24 4
gpt4 key购买 nike

我正在尝试将一个页面重定向到另一个页面,并且成功运行。但是我试图将第一页重定向到另一个带有广告的页面。五秒钟后,此页面将重定向到另一个页面。

我正在尝试通过这样做来做到这一点:

<?php
include('ads.php');
?>
<?php
sleep(2);
$url = $_GET['url'];
header("Location: ".$url."");
exit;
?>

然而,它在 ads.php 中完美地显示了广告,但它在五秒后没有重定向。我在网络浏览器中收到此错误:

Warning: Cannot modify header information - headers already sent by 
(output started at /home/nucleusi/public_html/adverts/ads.php:1)
in /home/nucleusi/public_html/adverts/index.php on line 7

我将重定向到的典型链接是这样的:

http://domain.com/adverts/index.php/?url=http%3A%2F%2Fitunes.apple.com%2Fmx%2Falbum%2Fstill-got-the-blues%2Fid14135178%3Fi %3D14135158

最佳答案

在首页(广告前)doctype或html标签之前:

<?php header("location: adlocationhere.php"); ?>

然后在广告页上放这个:

<?php header("refresh:5;url=secondredirectafter5seconds.php"); ?>

这将立即重定向您的第一页,并在 5 秒后重定向您的第二页。希望这会有所帮助(如果将它放在 doctype 和 html 标记之前,它也应该摆脱无法修改标题信息)。

编辑:使用 javascript 也可能存在安全风险,因为任何用户都可以更改其位置。通过这种方式,您可以完全控制用户的定向位置。

关于php - 将一个页面重定向到另一个页面 5 秒,然后再次重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4574740/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com