Brendan Murty

Posts > Visitor redirection

5 Nov 2012

Redirecting a user consistently can be a challenging in a complex website, as you can't be sure which method (JavaScript or the HTTP location header) is most suitable. This can be handled with a rather simple PHP function:

function redirect($url){
		print '<script>window.location="'.$url.'"</script>';
		header('Location: '.$url);