// вот так попробуй if ($user_id && $headmod == 'mainpage') { header('Location: '. $home .'/cab/index.php'); exit; }