Redirect

An HTTP redirect instructs the client to navigate to a different URL. PHP performs redirects by sending a Location header with an appropriate HTTP status code: 301 for permanent redirect, 302 for temporary, or 303 for ‘see other’.

After sending the redirect header, execution should stop immediately with exit to prevent further output being sent to the client.

<?php

    // Temporary redirect
    header('Location: /new-page');
    exit;

    // Permanent redirect
    header('Location: https://example.com/new-page', true, 301);
    exit;

?>

Documentation

See also HTTP redirects and header().

Related : Hyper Text Transfer Protocol (HTTP), HTTP Code, HTTP Request Headers, Response, Universal Resource Locator (URL), Search Engine Optimization (SEO), SplSubject