Php headers

Here is some PHP header examples for send user or browser to different location. And wait for temporarily unavailable time.

Location

This example sends user to another page:


header("Location: http://www.mysqltuts.com/");
?>


Not Found

This example show the browser  : - pageNot found. Also very usefult to search engine crawlers

header("HTTP/1.0 404 Not Found");
?>

Moved Permanently

301 moved permanently (redirect): sends browser to new page.

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mysqltuts.com/new-page");
?>

Moved Temporarily

302 moved temporarily(redirect):

header("Location: http://www.mysqltuts.com/new-alternate-page");
?>

Service not avaliable

This example tells to browser "We are working now, go and come back later 10 minute later"


header("HTTP/1.1 503 Service Temporarily Unavailable");
header("Status: 503 Service Temporarily Unavailable");
header("Retry-After: 600");
?>

Related: Php headerPhp header examplesService Temporarily Unavailable404301302

Comments about : Mysql tutorial