|
PHP: redirect a user to another pageThis snippet redirects the user to another web page. Note that a redirect must be called before any HTML output has been sent to the browser. Note also that the script is exited after the redirect header has been sent to avoid further processing by the script (which can lead to unexpected behaviour). The call to <?php
// Common method
header('Location: http://www.example.com/index.html');
exit;
// Relative URLs work too
header('Location: index.html');
exit;
// Alternative method, wrapping call to header() in exit()
exit(header('Location: http://www.example.com/index.html'));
|