PHP header redirect
PHP header redirect
Redirect users to another page or site using header: Location
At times, you may find yourself moving pages around or even changing domain names. Using the header function of PHP we can direct visitors (and search engines for that matter) to the new location with 3 lines of code.
<?php
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: http://www.example.com/newpage.php');
exit;
?>
You can redirect visitors to a page or another domain/sub-domain. It is very important that you include the exit portion at the end of the code. This prevents PHP from processing any further.
References:
PHP header function - http://us.php.net/header
Post new comment