在我们的网站上,我们有一些项目编辑页面。当用户单击“保存”时,表单将发布到同一页面,然后重定向到下一页。出于某种原因,重定向需要很长时间(例如60秒)。
我在代码中放置了计时措施,我可以告诉你,代码本身没有任何内容执行的时间超过1秒。
以下是我用来重定向的内容:
header("Location: " . $url, true, 307 ); // 307 is temporary redirect
答案 0 :(得分:6)
以下是解决问题的方法:
header( 'Content-type: text/html; charset=utf-8' ); // make sure this is set
header("Location: " . $url, true, 307 ); // 307 is temporary redirect
echo "<html></html>"; // - Tell the browser there the page is done
flush(); // - Make sure all buffers are flushed
ob_flush(); // - Make sure all buffers are flushed
exit; // - Prevent any more output from messing up the redirect