dpea85385 2015-10-03 19:54
浏览 66

php配置(我认为)

I have 'upgraded' my server and the following doesn't work anymore.

It sits at the top of a page, and is supposed to set some cookies and reload the page with empty query string (and cookies set) if the original URL has the correct query string.

What happens now is that the desired page loads and is then immediately replaced by an attempt to load a non-existent page.

As I said, I reinstalled my server and now the same code works correctly on my production server but not on the reinstalled server. I'm running on Ubuntu 15.04 now. My guess is that I neglected some aspect of php/apache installation, but I really haven't a clue.

Thanks for any help you can give. -- Len

<?php
if ( array_key_exists('rId',$_GET) && $_GET['rId'] == 'auth' ){
     setcookie('authCode',$_GET['authCode']);
     setcookie('rId',$_GET['rId']);
     setcookie('GP_UID',$_GET['GP_UID']);
     if ( array_key_exists('license',$_GET) )
          setcookie('license',$_GET['license']);
     else
          setcookie('license',0);
     $pth = $_SERVER['REQUEST_URI'];
     $pth = substr($pth, 0, strrpos($pth,'/')+1)."index.html";
     $url = $_SERVER['SERVER_NAME'].$pth;
     echo "<!DOCTYPE HTML><html><head><META http-equiv='refresh' content='0;URL=http://" .$url. "'></head></html>";
     return;
     exit;
}
?>       
<html>
<body id="view2">
    <h1> Loaded </h1>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • doujiu7704 2015-10-03 21:12
    关注

    I would have put this into a comment, but I cannot do that yet ^^. Nevertheless I am pretty sure, you can solve your problems thatway:

    header( 'Location: '.$url); 
    die();
    

    Once I needed this type of content output, because I had to POST something somewhere after adding/storing/saving values:

    ...
    <html>
    <head>
    </head>
    <body>      
        <form name='foo' action='<? echo $url; ?>' method=POST>
         <input type=hidden name='bla' value='blubb' />
        </form>
        <SCRIPT FOR=window EVENT=onload LANGUAGE='JavaScript'>
         document.foo.submit();
        </SCRIPT>
    </body>
    </html>
    

    Then try to quit your PHP like you did or with exit(); or die();

    Another thing: Whenever you switch your Server you should check if the $_SERVER[xxxx]-keys are still available and like they have been. I had quite a lot of trouble because sometimes there might be slight differences.

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示