What Is a 302 Redirect?
Understand how HTTP 302 redirects work, when temporary redirects are appropriate, how they differ from 301 redirects and common implementation mistakes.
A 302 redirect is an HTTP redirect that tells a browser or other client that a resource is temporarily available at a different URL. The server responds with the 302 status code and provides a destination URL, usually through the Location header.
Unlike a 301 redirect, which communicates a permanent URL change, a 302 redirect is generally used when the original URL is expected to remain the preferred address. This makes 302 redirects useful for temporary experiments, short-term campaigns, maintenance situations and other temporary routing requirements.
What Does 302 Mean?
The HTTP 302 status code indicates that the requested resource is temporarily available at another location. The client can follow the URL provided by the server, while the original URL remains relevant as the intended resource address.
HTTP/1.1 302 Found
Location: https://example.com/temporary-pageThe Location header identifies the URL that the client should request next. Browsers normally follow this redirect automatically without requiring the user to manually enter the destination address.
How a 302 Redirect Works
A 302 redirect occurs when a server receives a request for one URL and responds with a temporary redirect instead of returning the requested resource directly. The client then follows the Location header and requests the temporary destination.
| Step | Action |
|---|---|
| 1 | Client requests the original URL |
| 2 | Server returns HTTP 302 |
| 3 | Response contains a Location header |
| 4 | Client requests the temporary destination |
| 5 | Destination response is returned |
Simple Example
Imagine that a product page is temporarily unavailable because a special campaign version is being tested. The original URL can temporarily redirect visitors to the campaign page while the original address remains the long-term destination.
https://example.com/product
↓
302 Redirect
↓
https://example.com/special-offerWhen the campaign ends, the redirect can be removed and the original URL can once again serve its normal content.
When Should You Use a 302 Redirect?
A 302 redirect is appropriate when the change is temporary and the original URL is expected to become active again. The important consideration is whether the destination should replace the original URL permanently or only serve visitors for a limited period.
- Temporarily redirecting users during maintenance.
- Running short-term marketing campaigns.
- Testing an alternative page or experience.
- Temporarily changing where traffic is sent.
- Redirecting users based on temporary application conditions.
- Serving a temporary destination while an original resource remains active.
302 Redirects for A/B Testing
Temporary redirects can be used as part of certain testing scenarios where users are temporarily sent to another version of a page. However, A/B testing should be implemented carefully so that search engines do not receive confusing signals or accidentally treat test URLs as permanent replacements.
302 Redirects During Maintenance
A website or individual feature may temporarily redirect visitors while maintenance is performed. Once the maintenance is complete, the redirect can be removed and the original URL can return to normal operation.
/checkout
↓ 302
/maintenanceThe exact implementation depends on the application. In many cases, displaying a maintenance page directly may be preferable to redirecting, especially when the original URL should remain visible in the browser.
302 Redirect vs 301 Redirect
The most important distinction between 302 and 301 redirects is their intended permanence. A 301 communicates that the original URL has permanently moved, while a 302 generally communicates that the alternate location is temporary.
| Feature | 301 | 302 |
|---|---|---|
| Meaning | Permanent redirect | Temporary redirect |
| Original URL | Replaced by new URL | Remains preferred |
| Typical use | Permanent migration | Temporary routing |
| SEO intent | Signals a permanent move | Signals a temporary move |
| Common example | Changed URL structure | Temporary campaign |
Why Choosing the Correct Status Matters
Redirect status codes communicate intent to browsers, crawlers and other clients. Using a temporary redirect for a permanent migration can make the intended URL relationship less clear, while using a permanent redirect for a temporary situation can suggest that the original URL should no longer be preferred.
302 Redirects and SEO
Search engines generally interpret a 302 as a temporary change rather than a permanent replacement. This means the original URL can remain the primary URL while the temporary destination serves users for the duration of the redirect.
The exact treatment of redirects can depend on the circumstances, redirect implementation and how consistently the website communicates its preferred URLs. A 302 should therefore be used when the temporary nature of the redirect accurately reflects the site's intended behavior.
302 Redirects and Canonical URLs
Redirects and canonical URLs solve different problems. A redirect sends the client to another URL, while a canonical link element tells search engines which URL should generally be considered the preferred version among similar or duplicate pages.
| Mechanism | Purpose |
|---|---|
| 302 redirect | Temporarily sends visitors to another URL |
| 301 redirect | Permanently sends visitors to another URL |
| Canonical URL | Identifies the preferred URL for indexing |
A canonical URL should not be added automatically just because a page uses a 302 redirect. The correct configuration depends on which URL should ultimately be considered the primary version.
302 Redirects and Internal Links
If a temporary redirect is used for a short period, existing internal links can continue pointing to the original URL when that URL remains the intended destination. If the temporary routing becomes permanent, the site should be updated accordingly and the redirect status should be reconsidered.
302 Redirects and Sitemaps
XML sitemaps should generally contain the URLs that a website considers its preferred indexable pages rather than temporary redirect destinations. If a temporary redirect is introduced, review the sitemap to make sure it still reflects the site's intended URL structure.
302 Redirects in Apache
Apache can create temporary redirects through server configuration or .htaccess files. The Redirect directive can be used for simple path-based redirects.
Redirect 302 /old-page https://example.com/temporary-pageApache rewrite rules can also explicitly specify a 302 response when more advanced conditions or URL patterns are required.
RewriteEngine On
RewriteRule ^old-page$ /temporary-page [R=302,L]302 Redirects in Nginx
Nginx can issue a temporary redirect with the return directive. This approach is useful when a specific location needs to temporarily point visitors somewhere else.
location = /old-page {
return 302 https://example.com/temporary-page;
}Testing a 302 Redirect
A redirect should be tested to verify that the server returns the expected status code and destination. Command-line tools such as curl can show the response headers without requiring a browser.
curl -I https://example.com/old-pageThe response should contain a 302 status and normally include a Location header pointing to the temporary destination.
Following Redirects with curl
The -L option tells curl to follow redirects automatically. This is useful when testing the complete redirect path and checking the final response.
curl -I -L https://example.com/old-pageRedirect Chains with 302
A redirect chain can contain 302 responses just like it can contain 301 responses. For example, an original URL might temporarily redirect to an intermediate URL that itself redirects to another destination.
/original
↓ 302
/temporary
↓ 302
/finalUnnecessary redirect chains increase the number of requests and make troubleshooting more difficult. Temporary redirects should therefore be kept as simple as possible.
Redirect Loops
A redirect loop occurs when two or more URLs continually redirect to one another. For example, a temporary rule might send /page-a to /page-b while another rule sends /page-b back to /page-a.
/page-a
↓ 302
/page-b
↓ 302
/page-aRedirect loops usually indicate conflicting rules or application logic. They should be fixed immediately because browsers and crawlers cannot reach the intended destination.
Common 302 Redirect Mistakes
- Using 302 for a permanent URL migration.
- Leaving temporary redirects active indefinitely.
- Creating redirect chains.
- Creating redirect loops.
- Redirecting users to unrelated pages.
- Forgetting which URL should remain canonical.
- Using overly broad rewrite conditions.
- Failing to test redirect behavior after deployment.
When a 302 Becomes a 301
A temporary redirect may eventually become permanent. For example, a website might initially redirect visitors during a migration test and later decide that the new URL should permanently replace the original. At that point, the redirect strategy should be reviewed and a permanent redirect may be appropriate.
Temporary:
old-url → 302 → new-url
Permanent:
old-url → 301 → new-url302 Redirect Best Practices
- Use 302 when the redirect is genuinely temporary.
- Keep the original URL as the preferred address when appropriate.
- Avoid unnecessary redirect chains.
- Check for redirect loops after configuration changes.
- Use precise server rules.
- Test both the HTTP status and Location header.
- Review long-running temporary redirects.
- Update the redirect to 301 if the move becomes permanent.
- Keep internal links and sitemaps aligned with the intended URL structure.
Frequently Asked Questions
What is a 302 redirect?
A 302 redirect is an HTTP temporary redirect that sends clients to another URL while indicating that the original URL is still the intended resource address.
What is the difference between 301 and 302 redirects?
A 301 communicates that a URL has permanently moved, while a 302 generally indicates that the redirect is temporary.
Is a 302 redirect bad for SEO?
No. A 302 is appropriate when a redirect is genuinely temporary. Problems can arise when a 302 is used for a change that is actually permanent or when temporary redirects are poorly configured.
Can I use a 302 for website maintenance?
Yes, a 302 can be used for temporary routing during maintenance, although serving a maintenance response directly may sometimes be more appropriate than redirecting the original URL.
Should a 302 redirect stay forever?
Normally no. A 302 communicates a temporary situation. If the destination eventually becomes the permanent replacement, consider changing the redirect strategy to a permanent redirect.
Does a 302 redirect change the original URL permanently?
No. A 302 is intended to communicate that the original URL remains relevant and the alternate destination is temporary.
Helpful SEO and Server Tools
A Redirect Chain Analyzer helps identify redirect chains and loops, an .htaccess Generator creates Apache configuration rules, an Apache Rewrite Generator assists with rewrite and redirect patterns, an Nginx Config Generator helps create Nginx server rules, and a Canonical URL Generator helps produce canonical URL values for pages that need an explicit preferred address.
Conclusion
A 302 redirect tells clients that a resource is temporarily available at another URL while the original address remains the intended location. It is useful for temporary campaigns, testing, maintenance and other short-term routing scenarios. The key difference from a 301 redirect is the intended permanence of the change. By choosing the correct status code, avoiding redirect chains and loops, testing server behavior and reviewing temporary redirects over time, developers can maintain clear URL structures and predictable behavior for both users and search engines.