文件redirect.php包含此代碼:如何在PHP重定向
<?php
$url = $_SERVER["PHP_SELF"];
$path = explode("?q=", $url);
$last = end($path);
header('Location: http://mywebsite2.com/something&q='.$last);
?>
然而,當我去http://mywebsite.com/redirect.php?q=anything,它顯示了一個錯誤:
Cannot modify header information - headers already sent by".
如何解決呢?
之前把你的'<?php'擺脫空白 –