function redirect($Url) { if (!headers_sent()){ header("Location: $Url"); }else{ echo "<script type='text/javascript'>window.location.href='$Url'</script>"; echo "<noscript><meta http-equiv='refresh' content='0;url=$Url'/></noscript>"; } exit; } #Result redirect('https://aparat.com');