HTTP 303 See Other

The HTTP See Other status code is used when performing redirects.

1843 views

Edited: 2020-01-04 22:38

The HTTP 303 See Other status code tells the browser that the response for the request can be found at a different location, wheres the new location should be provided in the location header.

Do not use this for redirects. If a page is moved, you should instead use the 301 response code.

Below is an example of how the 303 See Other redirect would look:

HTTP/1.1 303 See Other
Location: http://beamtic.com/

To deliver a 303 response with PHP, we can write a simple one-liner using the header function:

header("Location: https://example.com/",TRUE,303);

More ways to send a 303 response code

A more readable way of doing it would be by using http_response_code, this way we will not have to memorize the order of the parameters in the header function:

http_response_code(303);
header('Location: https://example.com/');

To instead send the headers raw, you would need to both make sure you use the right protocol, and be very careful not to misspell the headers:

header(set_protocol() . ' 303 See Other');
header('Location: https://example.com/');

function set_protocol() {
  $supported_protocols = array(
    'HTTP/2.0' => true,
    'HTTP/1.1' => true,
    'HTTP/1.0' => true,
  );
  $protocol = $_SERVER["SERVER_PROTOCOL"];
  if (!isset($supported_protocols["$protocol"])) {
    $protocol = 'HTTP/1.0';
  }
  return $protocol;
}

Tell us what you think:

  1. An in-dept look at the use of headings (h1-h6) and sections in HTML pages.
  2. Pagination can be a confusing thing to get right both practically and programmatically. I have put a lot of thought into this subject, and here I am giving you a few of the ideas I have been working with.
  3. The best way to deal with a trailing question mark is probably just to make it a bad request, because it is a very odd thing to find in a request URL.
  4. How to optimize image-loading and automatically include width and height attributes on img elements with PHP.
  5. HTTP headers are not case-sensitive, so we are free to convert them to all-lowercase in our applications.

More in: Web development