302 Status Code - Found
What is 302 status code?
The HTTP Status Code 302, labeled as "Found" or sometimes referred to as "Temporary Redirect", is a redirection response status code. It suggests that the resource the client is trying to reach temporarily resides at a different URI. Unlike the 301 Moved Permanently, which indicates a permanent move, the 302 Found
status communicates a temporary redirection, implying that clients should continue using the original URI for future requests.
Understanding 302 status code
Temporary Redirection: The
302 Found
status code communicates that the resource the client is seeking has been temporarily relocated to another URI. It's a hint that this redirection might not persist indefinitely.HTTP/1.1 302 Found
Location Header: Alongside the
302 Found
status code, theLocation
header is often included, pinpointing the temporary URI where the requested resource can currently be found.Location: <https://www.example.com/temporary-resource>
Why 302 status code?
The 302 Found status code is beneficial when the content has been shifted to another location for a limited period. For example, it can be used during website maintenance, A/B testing, or for promotional content that will only be relevant for a short duration.
Benefits of 302 status code
Flexibility: The
302
redirect offers flexibility, enabling temporary content shifts without affecting the original URL's SEO value or user bookmarks.SEO: Unlike the
301
redirect, search engines recognize the temporary nature of a302
redirect and typically keep the original URL indexed.
How does 302 Http status code work?
Client Sends a Request:
The client sends a request to a specific resource on the server using a URL.
Server Sends a Response:
The server, discerning that the resource has been temporarily moved, returns a HTTP Response Code 302, coupled with a
Location
header pointing to the new URI.
Components of a 302 Found Response
Within a 302 Found
response, you'll typically encounter:
Status Line: The initial line of the response, signaling the
302 Found
status code.
Headers: The
Location
header is pivotal, as it indicates the new temporary URI where the resource can be accessed.
Examples of 302 Http Status Code Found
Website Maintenance:
Response:
Here, a user profile page is temporarily unavailable due to maintenance. Users trying to access it are met with a 302 Found
status code, redirecting them to a maintenance notification page. Once maintenance concludes, the original URL will again provide direct access to the user profile page.
E-Commerce Site Sale:
Request:
GET /summer-sale HTTP/1.1 Host: www.fashionstore.com
Response:
HTTP/1.1 302 Found Location: <https://www.fashionstore.com/winter-clearance>
In this example, an e-commerce site has ended its summer sale and started a winter clearance. Users trying to access the summer sale page are met with a 302 Found
status code, redirecting them to the winter clearance page. Once the winter clearance ends, the summer sale URL can be used again for the next summer sale.
Final Thoughts
The 302 Found
status code allows developers to temporarily reroute traffic without affecting the SEO value of the original URL or causing any long-term changes. Grasping the 302 Found http status code is essential for developers working with websites or web applications, as it provides a tool for managing temporary content changes, website maintenance, or promotional campaigns.
Learn about other codes in 3xx family of HTTP status codes such as 301 Status Code, 304 Status Code and 307 Status Code.
Explore more from Akto
Blog
Be updated about everything related to API Security, new API vulnerabilities, industry news and product updates.
Events
Browse and register for upcoming sessions or catch up on what you missed with exclusive recordings
CVE Database
Find out everything about latest API CVE in popular products
Test Library
Discover and find tests from Akto's 100+ API Security test library. Choose your template or add a new template to start your API Security testing.
Documentation
Check out Akto's product documentation for all information related to features and how to use them.