How to Code a PHP Redirect - PHP Header Redirect
Redirection in PHP can be done using the header()
function.
To setup, a simple redirect simply creates an index.php file in the directory you wish to redirect from with the following content:
# redirct to another website
<?php header('Location: http://www.redirect.to.url.com/'); ?>
Where http://www.redirect.to.url.com
is the URL you wish the users to be redirected to.
We can also redirect to another page on the same domain and we can do it with the following content:
# redirct to another page on same website
<?php header('Location: /another-page'); ?>