header(“location”) causes [500] internal server error?

前端 未结 4 641
星月不相逢
星月不相逢 2020-12-04 03:16

I cannot figure out what could be causing this error. My Apache log is not recording any errors in the access log or error log regarding the page, yet somehow whenever I unc

相关标签:
4条回答
  • 2020-12-04 03:55

    Try to use a fully formed URL:

    header("Location: http://{$_SERVER['HTTP_HOST']}/offices/page-".ceil($cache->size() / 15));
    
    0 讨论(0)
  • 2020-12-04 03:56

    The script continues to execute after your header() call. You need put exit; immediately after it. This shouldn't cause a 500 error, though.

    Edit: Evidently this worked - meaning your problem is probably in some related code further down the page?

    0 讨论(0)
  • 2020-12-04 03:57

    I had the same thing going on. After repeatedly banging my head on the monitor, it isn't the header("Location: myPage.php"); line that is broken - it is myPage.php that is broken! Try redirecting to another page. I hope I save someone else time

    0 讨论(0)
  • 2020-12-04 04:05

    Another reason might be - you need to remove space after location :

    header("location :
    header("location:

    If that's not your problem, then try to check the php & apache error logs.

    0 讨论(0)
提交回复
热议问题