By using this site you agree to the use of cookies.

Learn more

Share via:

HTTP Location Header

The Location Header is sent when performing redirects, a status code indicates the type of redirect, an example would be permenant (301) and temporary (302).

Edited: 2017-06-15 13:49

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

The HTTP location header can be sent in response to any request that matches content which has been moved. The browser should automatically pass on the request to the location indicated in this header.

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


To perform a redirect in PHP, we can use the header function. Assuming we are redirecting to /other-page from the current requested page, we can do like below:

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

Note. Header's should always be sent after any output, such as that produced by echo, print, or by exiting PHP with "?$gt;", otherwise you will just get "headers already sent" errors.