Skip to content

Instantly share code, notes, and snippets.

@hctilg
Created April 1, 2024 08:08
Show Gist options
  • Save hctilg/635cf96991a4104948ee38230c29648e to your computer and use it in GitHub Desktop.
Save hctilg/635cf96991a4104948ee38230c29648e to your computer and use it in GitHub Desktop.
redirect
<?php
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>";
}
}
redirect("https://google.com/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment