logout.php不会重定向到服务器上的目标页面,但可以在localhost上运行

logout.php不会重定向到服务器上的目标页面,但可以在localhost上运行

问题描述:

I am trying to to understand why a simple logout.php script works on localhost but not on live server. Thanks in advance for any help.

here is the entire logout.php file

<?php//Start the session
session_start();

//Terminate the session
session_unset();
//Redirect users to login page
header('Location:  http://www.somewebsite.com/login');
exit(); 


?>

As you mentioned in your comments, you had a newline in front of your <?php tag which caused output headers to be sent.

Resolve by removing the newline (or space, or tab, etc.)