douh9817 2013-01-08 06:34
浏览 106
已采纳

header(“Location:mypage.php”)在上传到其他服务器后无法正常工作

In my page I used header location for redirection in twitter login. But it is working fine in my server. But it is not working after uploaded the files to other server

header("Location: login-twitter.php");

When try to see what error in the page and used the below code, I see the following warning message.

error_reporting(E_ALL); ini_set('display_errors', 'On'); 

Warning: Cannot modify header information - headers already sent by (output started at /vhosts/www/samplehosts/mysite.com/samplefolder/header.php:258) in /vhosts/www/samplehosts/mysite.com/samplefolder/signin.php on line 24

The redirection is not working on any of the pages in my site. Anybody can help me to solve this problem

signin.php

if (array_key_exists("login", $_GET)) {

    $oauth_provider = $_GET['oauth_provider'];

    if ($oauth_provider == 'twitter') {

error_reporting(E_ALL); ini_set('display_errors', 'On'); 

        header("Location: login-twitter.php");

    }

}



<li class="twitter">
<a  class="twitter_login" href="?login&oauth_provider=twitter"  rel="nofollow">
<img src="images/twitter.png" width="206" height="33" >
</a>
</li>

But after click the twitter button just it shows the header URL as

http://mysite.com/?login&oauth_provider=twitter

and not redirecting to twitter login page.

  • 写回答

2条回答 默认 最新

  • douzi5214 2013-01-10 06:53
    关注

    As per my understanding, your problem is that:

    header("location:[XYX.PHP]") is not working.
    

    It generally does not work due to some output is print already on the page. Please use

    ob_start();

    at very the beginning of the page. This starts output buffering. And the redirection works.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊