简体   繁体   中英

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

After enabling HTTPS on the website my location headers don't respond anymore. Never had this problem before.

I've tried different thing to fix it, but it still won't work

<?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"); should be the first output done in a script ..

You need to remove the header("HTTP/1.1 200 OK"); statement or pu it inside the if condition like so:

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

also make sure nothing is echoes /printed out in check.php as nothing should be echoed out before the header() function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM