这是我上传到我的网络服务器的简单代码,以查找为什么标头在主应用程序中不起作用。即便如此,我也无法使用i页面服务器。这适用于localhost wamp服务器。
<?php
ob_start();
header('Location: login-twitter.com');
ob_end_flush();
?>
我也尝试过以下代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<h1>Hello</h1>
<?php
ob_start();
header('Location: login-twitter.com');
ob_end_flush();
?>
</body>
</html>
答案 0 :(得分:2)
尝试使用标题(&#39;位置:http://www.login-twitter.com/&#39;);而不是标题(&#39;位置:login-twitter.com&#39;);
答案 1 :(得分:1)
您必须在html开始标记之前执行重定向(标题('Location:login-twitter.com');)。
答案 2 :(得分:1)
在文件的最开头,添加以下行:
甚至在HTML <!Doctype>
<?php session_start();
ob_start();
?>
注意:如果您在浏览器上有一些HTML输出,则不会发生重定向。
答案 3 :(得分:1)
试试这个:
<script type="text/javascript">
window.location.assign('http://www.login-twitter.com');
</script>