簡體   English   中英

開啟HTTPS后,PHP標頭('Location:index.php')不起作用

[英]PHP header('Location: index.php') not working after turning on HTTPS

在網站上啟用HTTPS后,我的位置標頭不再響應。 從來沒有過這個問題。

我已經嘗試過其他方法來修復它,但仍然無法正常工作

<?php
include('check.php');

header("HTTP/1.1 200 OK");
if(empty($_SESSION)){


} else {
    header("Location: http://example.com/admin.php");
}
?>

header("Location: http://example.com/admin.php"); 應該是在腳本中完成的第一個輸出..

您需要刪除header("HTTP/1.1 200 OK"); if條件中聲明或添加它,如下所示:

<?php
include('check.php');
if(empty($_SESSION)){
    header("HTTP/1.1 200 OK");
} else {
    header("Location: http://example.com/admin.php");
}
?>

還應確保在check.php中沒有回顯/打印出任何內容,因為在header()函數之前應沒有任何回顯內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM