2

I want to present the user with a holding page that is replaced with the index.html page of a new website once the website has been created.

At the moment, I can only do it by having a timed refresh.

<?php
//DB connection and posting 

$location="http://" . $id;
header("refresh: 240; url=$location");
?>

<?
ob_start(); 
?> 

..... HTML code of holding page

<? 
echo ob_get_clean();
?>

Slightly out of my depth with this but have tried putting the holding page code at the beginning of the code and then inserting the following code at the end to validate the index.html file. But no luck . Any help much appreciated

<?
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $location);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);

start:
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($retcode == "200")
    {
     header("url=$location");
    }   
else
    {
        sleep(5);
    goto start;
    }
?>
4

2 回答 2

1

代替

if ($retcode == "200")
    {
     header("url=$location");
    }

尝试使用

if ($retcode == "200")
    {
     echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL='.$location.'">';
    }  

它将进行客户端重定向。我想这会对你有所帮助!

于 2012-12-09T15:58:54.977 回答
0

我怀疑是否有一个干净纯粹的 html 解决方案。

您应该为此使用客户端脚本:您嵌入了一个小的 javascript 函数,该函数可以定期轮询服务器,或者(首选)使用长轮询策略来确定 html 页面是否已经存在。如果结果是肯定的,它会重定向浏览器。

于 2012-12-09T15:53:45.337 回答