By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

HTTP Location Header

Reference on the HTTP Location Header - explains how its used, and how to send it from the server.

Edited: 2013-07-05 12:06

The HTTP Location header tells the browser to load another page, it is commonly used together with a general status message, such as the 303 See Other message.

The HTTP location header is delivered by the server to the browser in a response to a HTTP GET Request.

While it may work to use a relative path in the location header, it is recommended to use the absolute path for the resource.

How to do Redirects with PHP

When performing a location redirect with PHP, we may also want to send a relevant HTTP status code. To do this, the header function is used – both to deliver the status code, and to deliver the URL that we want the browser to go to instead. I.e.

header('HTTP/1.1 303 See Other');

See also

  1. List of HTTP Response Codes
  2. Absolute and Relative Paths
  3. Redirects in PHP