File redirect.php contain this code:
<?php
$url = $_SERVER["PHP_SELF"];
$path = explode("?q=", $url);
$last = end($path);
header('Location: http://mywebsite2.com/something&q='.$last);
?>
However, when I go http://mywebsite.com/redirect.php?q=anything, it shows an error:
Cannot modify header information - headers already sent by".
How to fix it?