HTTP 302 status code


302 Found

HTTP 302 状态码是什么意思

##Requires client Performs a temporary redirect (original description phrase is "Moved Temporarily"). Because such redirects are temporary, the client should continue to send future requests to the original address. This response is cacheable only if specified in Cache-Control or Expires.

The new temporary URI should be returned in the Location field of the response. Unless this is a HEAD request, the response entity should contain a hyperlink to the new URI and a brief description.

If this is not a GET or HEAD request, the browser prohibits automatic redirection unless confirmed by the user, because the conditions of the request may change accordingly.
Note: Although the RFC 1945 and RFC 2068 specifications do not allow the client to change the request method when redirecting, many existing browsers treat the 302 response as a 303 response and use the GET method to access the URI specified in the Location. , regardless of the originally requested method. Therefore status codes 303 and 307 were added to clarify what response the server expects from the client.

How to implement 302 status code in PHP?

<?php header("Location: http://www.xxx.com");

In detail, the 301 and 302 status codes both indicate redirection, which means that the browser gets the status code returned by the server. Then it will automatically jump to a new URL address. This address can be obtained from the Location header of the response (the effect the user sees is that the address A he entered instantly changes to another address B) - this is what they have in common. point. The difference is. 301 means that the resource at the old address A has been permanently removed (this resource is no longer accessible). The search engine will also exchange the old URL for the redirected URL while crawling the new content; 302 means that the resource at the old address A The resource is still there (still accessible). This redirect only temporarily jumps from the old address A to address B. The search engine will crawl the new content and save the old URL. [Recommended reading: HTTP 301 status code]