Jul 28, 2022 7 min read

3xx Status Codes (Redirection)

Complete list of 3xx HTTP status codes explaining all redirection related server responses from 300 to 308 to troubleshoot HTTP connection.

3xx Status Codes (Redirection)
3xx Status Codes (Redirection)
Table of Contents

Types of HTTP Status Codes

Before moving on to 1xx status codes, it is best to know that there are five categories into which we can divide HTTP response codes.

  • 1xx Status Codes for information.
  • 2xx Status Codes indicate that a request has been processed properly.
  • 3xx Status Codes for redirection advise the client that the requested resource is accessible elsewhere on the server.
  • 4xx Status Codes for client errors primarily comes from the browser, because the required parameters to visit the requested URL are lacking.
  • 5xx Status Codes for Server Errors indicate that the request could not be processed.

Introduction

A 3xx Redirection status code indicates that you have been diverted and additional steps are necessary to complete the request. You shouldn't be afraid to have 3xx redirect status codes on your website because redirects are a normal aspect of the internet. An effective redirect indicates that the request was received, but the resource was located elsewhere.

Your CMS will frequently guide the user to the new path if you attempt to view a webpage through the old path after it has changed. The request will ultimately succeed with a 2xx, but not before passing through the 3xx redirection.

300 Multiple Choices Status Code

The server wants the user agent to participate in reactive negotiation to choose the most suitable representation(s) for its requirements1.

In the event that the server has a preferred option, the server SHOULD produce a Location header field providing the URI reference of the preferred option. For automated redirection, the user agent MAY utilize the value of the Location field.

When the user or user agent submits a request using a method other than HEAD, the server SHOULD generate a payload in the 300 response that includes a list of representation metadata and URI reference(s) from which the user or user agent can select the one they prefer. If the user agent recognizes the specified media type, it MAY select something from that list automatically. Because HTTP seeks to maintain its independence from the description of its payloads, this specification does not specify a precise format for automatic selection. In reality, the representation is offered in a parse-friendly format that is thought to be acceptable by the user agent, as established through shared design or content negotiation, or in a widely used hypertext format.

A 300 response is automatically cacheable unless the method definition or explicit cache controls specify otherwise.

Note: The URI header field was originally intended to provide a list of other representations for the 300 status code, making it applicable for 200, 300, and 406 answers as well as responses to the HEAD method. However, the succeeding proposal Alternates and the URI were both omitted from this specification due to a lack of deployment and disagreements over syntax. Although deployment is a chicken-and-egg issue, it is possible to transmit the list using a set of Link header fields3 with a relationship of “alternative” between each one.

References for Code 300

  • HTTP Status Symbol for Rails :multiple_choices
  • HTTP Status Constant for Symfony Response::HTTP_MULTIPLE_CHOICES
  • HTTP Status Constant for Python3+ http.client.MULTIPLE_CHOICES
  • HTTP Status Constant for Go http.StatusMultipleChoices
  • HTTP Status Constant for Python3.5+ http.HTTPStatus.MULTIPLE_CHOICES
  • HTTP Status Constant for Python2 httplib.MULTIPLE_CHOICES

301 Moved Permanently Status Code

Where possible, clients with link-editing capabilities should immediately re-link references to the actual request URI to one or more of the new references given by the server.

A preferred URI reference for the new permanent URI should be generated by the server and included in the Location header field of the response. The Location field value COULD be used by the user agent to perform automated redirection. The server often includes a brief hypertext message with a hyperlink to the new URI in the response payload (s).

Note: For future requests, a user agent MAY switch the request method from POST to GET due to historical considerations. The 307 Temporary Redirect status code can be used in place of this one if this behaviour is undesirable.

Unless explicitly stated otherwise by the method description or explicit cache controls, a 301 response is cacheable by default.

Reference for Code 301

  • HTTP Status Symbol for Rails  :moved_permanently
  • HTTP Status Constant for Symfony Response::HTTP_MOVED_PERMANENTLY
  • HTTP Status Constant for Python3.5+ http.HTTPStatus.MOVED_PERMANENTLY
  • HTTP Status Constant for Go http.StatusMovedPermanently
  • HTTP Status Constant for Python3+ http.client.MOVED_PERMANENTLY
  • HTTP Status Constant for Python2 httplib.MOVED_PERMANENTLY

302 Found Status Code

In the response, the server SHOULD create a Location header field that includes a URI reference for the alternative URI. The Location field value COULD be used by the user agent to perform automated redirection. Typically, the server's response payload includes a brief hypertext comment with a hyperlink to the various URIs (s).

References for Code 302

  • HTTP Status Symbol for Rails :found
  • HTTP Status Constant for Python2 httplib.FOUND
  • HTTP Status Constant for Go http.StatusFound
  • HTTP Status Constant for Python3.5+ http.HTTPStatus.FOUND
  • HTTP Status Constant for Python3+ http.client.FOUND
  • HTTP Status Constant for Symfony Response::HTTP_FOUND

303 See Other Status Code

A user agent can issue a retrieval request (a GET or HEAD request if using HTTP) directed at that URI, which may also be redirected, and then provide the final outcome as a response to the initial query. It should be noted that the effective request URI is not regarded as being comparable to the new URI in the Location header field.

Any HTTP method is compatible with this status code. Since doing so delivers the information matching to the POST answer in a form that can be separately identified, bookmarked, and cached, independent of the original request. It is typically used to allow the output of a POST action to redirect the user agent to a chosen resource.

When a GET request receives a 303 answer, it means that the target resource cannot be delivered by the server through HTTP from the origin server. The Location field value, however, relates to a resource that provides descriptive information about the target resource. Performing a retrieval on that other resource can produce a representation that is helpful to recipients without indicating that it reflects the original target resource. Please take note that HTTP does not address the issues of what can be represented, whether representations are sufficient, or what would be a good description.

A brief hypertext comment with a hyperlink to the same URI reference provided in the Location header field should be included in the representation of a 303 response, except responses to a HEAD request.

References for Code 303

  • HTTP Status Symbol for Rails :see_other
  • HTTP Status Constant for Python3.5+ http.HTTPStatus.SEE_OTHER
  • HTTP Status Constant for Python3+ http.client.SEE_OTHER
  • HTTP Status Constant for Go http.StatusSeeOther
  • HTTP Status Constant for Python2 httplib.SEE_OTHER
  • HTTP Status Constant for Symfony Response::HTTP_SEE_OTHER

304 Not Modified Status Code

In other words, the request indicates that the client, who made the request conditional, already has a valid representation. As a result, the server is redirecting the client to make use of that stored representation as if it were the payload of a 200 OK response, negating the requirement for the server to transfer a representation of the target resource.

Any of the following header fields that would have been delivered in a 200 OK response to the same request must be generated by the server sending a 304 response: Date, ETag, Expires, Cache-Control, Content-Location, and Vary.

A sender SHOULD NOT generate representation metadata other than the aforementioned fields unless such representation metadata exists for the purpose of directing cache updates. The purpose of a 304 response is to minimize information transfer when the recipient already has one or more cached representations (e.g., Last-Modified might be useful if the response does not have an ETag field).

Requirements for a cache that gets a 304 response are laid out. The proxy SHOULD transmit the 304 response to the client if the conditional request came from an outbound client, such as a user agent sending a conditional GET to a shared proxy with its own cache.

A 304 response is always concluded by the first empty line following the header fields; it is not permitted to include a message-body.

References for Code 304

  • HTTP Status Symbol for Rails :not_modified
  • HTTP Status Constant for Symfony Response::HTTP_NOT_MODIFIED
  • HTTP Status Constant for Python3.5+ http.HTTPStatus.NOT_MODIFIED
  • HTTP Status Constant for Go http.StatusNotModified
  • HTTP Status Constant for Python2 httplib.NOT_MODIFIED
  • HTTP Status Constant for Python3+ http.client.NOT_MODIFIED

305 Use Proxy Status Code

When a client receives the status code 305, it is advised to connect to a proxy and submit the same request there. Due to security issues, this response code has been deprecated.

307 Temporary Redirect Status Code

The client should keep utilizing the initial effective request URI going forward because the redirection can change over time.

In the response, the server SHOULD create a Location header field that includes a URI reference for the alternative URI. The Location field value COULD be used by the user agent to perform automated redirection. Typically, the server's response payload includes a brief hypertext comment with a hyperlink to the various URIs (s).

The only difference between this status code and 302 Found is that it prevents switching from POST to GET requests. No equivalent counterpart for 301 Moved Permanently is defined by this specification.

References for Code 307

  • HTTP Status Symbol for Rails :temporary_redirect
  • HTTP Status Constant for Python2 httplib.TEMPORARY_REDIRECT
  • HTTP Status Constant for Python3.5+ http.HTTPStatus.TEMPORARY_REDIRECT
  • HTTP Status Constant for Go http.StatusTemporaryRedirect
  • HTTP Status Constant for Python3+ http.client.TEMPORARY_REDIRECT
  • HTTP Status Constant for Symfony Response::HTTP_TEMPORARY_REDIRECT

308 Permanent Redirect Status Code

Where possible, clients with link editing capabilities should immediately re-link references to the actual request URI to one or more of the new references given by the server.

The response from the server SHOULD include a Location header field with a preferred URI reference for the new permanent URI. The Location field value COULD be used by the user agent to perform automated redirection. The server often includes a brief hypertext message with a hyperlink to the new URI in the response payload (s).

A 308 answer is cacheable by default, unless the method definition or explicit cache controls state otherwise.

The only difference between this status code and 301 Moved Permanently is that it prevents switching from POST to GET requests.

Reference for Code 308

  • HTTP Status Constant for Symfony Response::HTTP_PERMANENTLY_REDIRECT

Conclusion

The status of the request is indicated by the 3xx server response codes that the web server gives. These codes are used by website owners for troubleshooting to determine the status of the HTTP transaction. Out of all 3xx server response codes, 301 is the most common. The rationale is straightforward: 301 redirects are necessary for all webmasters to set up in order to maintain the pages' search engine rankings.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.