Skip to content
Softhat IT SolutionsSofthat IT Solutions

What is a 302 Redirect? And When Should You Use It

Learn what a 302 redirect is, how Google treats temporary redirects, when to use one instead of a 301, and how to set it up correctly.

AuthorRehmat Ullah5 min readUpdated
What is a 302 Redirect? And When Should You Use It

Understanding the different types of redirects is crucial for keeping a website healthy and easy to use. The 301 redirect is widely known, but the 302 redirect has its own job: handling temporary changes.

In this article, we explain what a 302 redirect is, how it differs from a 301 redirect, how Google treats it, and the situations where it is the right choice.

What is a 302 Redirect?

1. Definition:

  • A 302 redirect is a temporary redirect from one URL to another. It tells browsers and search engines that the requested page is temporarily available at a different location, and that the original URL should be kept.

2. How It Works:

  • When a user or search engine bot requests a URL with a 302 redirect, the server responds with HTTP status code 302 and the temporary address. The browser then loads that address automatically.
  • A 307 status code is also a temporary redirect. It works the same way but guarantees the request method stays the same (for example, a form POST stays a POST).

3. Impact on SEO:

  • An earlier version of this article said a 302 redirect does not pass link equity. That is misleading. The real difference is about canonicalization, meaning which URL Google indexes and shows.
  • According to Google's redirect documentation, permanent redirects (301, 308) are a signal that the target URL should be canonical. Temporary redirects (302, 307) don't send that signal, so Google generally keeps showing the original URL in search results.
  • A redirect is only one of the signals Google uses to choose a canonical URL, so a "temporary" 302 left in place for months sends mixed signals. So use a 302 only when you really plan to bring the original URL back.

When Should You Use a 302 Redirect?

1. A/B Testing:

  • If you test different versions of a page on separate URLs, Google's website testing guidance recommends a 302 (temporary) redirect, not a 301. It also recommends a rel="canonical" link on the test variants pointing to the original URL, and removing the test as soon as it ends.

2. Temporary Content Moves:

  • When a page needs to be taken down briefly for maintenance or updates, a 302 redirect can send visitors to a temporary page while the original URL remains the one search engines keep.

3. Seasonal or Promotional Pages:

  • During a short campaign, such as an Eid or 11.11 sale, you can temporarily redirect a category or landing page to the promotion page, then remove the redirect when the sale ends.

4. Website Redesign:

  • During a redesign, you may temporarily redirect a section while you rebuild it. Once the new URLs are final, switch any permanent changes to 301 redirects.

5. Handling Out-of-Stock Products:

  • Older advice suggested redirecting temporarily out-of-stock products to similar items. For most online stores, it is better to keep the product URL live, clearly show that the item is out of stock, and link to alternatives on the page. Mark the availability in your Product structured data.
  • Redirects can confuse shoppers who arrive from Google, social posts or WhatsApp shares expecting a specific product. If a product is permanently discontinued, redirect it with a 301 to the closest replacement or category, or return a 404 if nothing relevant exists.

6. Geo or Language Routing:

  • Some sites send visitors to a country or language version based on location. If you do this, keep the redirect temporary and let users switch versions. For search engines, use hreflang to connect the versions rather than relying on redirects alone.

How to Implement a 302 Redirect

1. Using .htaccess File (Apache Server):

For websites hosted on Apache servers, you can add 302 redirects by editing the .htaccess file. Example:

Redirect 302 /old-page.html https://www.example.com/new-page.html

2. Using Server Configurations (Nginx):

For websites hosted on Nginx servers, you can add 302 redirects in the server configuration file. Example:

rewrite ^/old-page.html$ https://www.example.com/new-page.html redirect;

3. Using CMS Plugins:

Many content management systems (CMS) like WordPress offer plugins to manage redirects without editing server files. Plugins such as Redirection or Rank Math let you choose the redirect type (301, 302 or 307) for each rule. Double-check the type, because some tools default to 301.

4. A Note on JavaScript Redirects:

The earlier version of this article presented a JavaScript redirect as a 302. It isn't. Code like the example below sends no HTTP status code at all; the browser simply navigates after the page loads:

window.location.replace("https://www.example.com/new-page.html");

Google can only see a JavaScript redirect after rendering the page, and its documentation says to use JavaScript redirects only if server-side or meta refresh redirects aren't possible. For a true temporary redirect, set a 302 or 307 on the server.

Best Practices for 302 Redirects

1. Use for Temporary Changes Only:

  • Use 302 redirects only for changes you will reverse. If the move becomes permanent, switch to a 301 redirect so Google treats the new URL as canonical.

2. Monitor Your Redirects:

  • Keep a list of temporary redirects with an end date. Review it regularly and remove or convert redirects that are no longer needed. A site crawler such as Screaming Frog will show the status code of each redirect.

3. Avoid Redirect Chains:

  • Redirect chains (URL A to URL B, then URL B to URL C) slow down page loads and add points of failure. Aim for a direct path from the original URL to the temporary URL.

4. Check How Google Sees the URL:

  • There is no Search Console setting to "notify" Google about temporary redirects; the status code itself is the signal. Use the URL Inspection tool in Google Search Console to see which URL Google has chosen as canonical and whether the redirect is being followed.

Conclusion

302 redirects are a useful tool for short-term URL changes. They tell Google to keep the original URL, which makes them right for A/B tests, brief maintenance and time-limited campaigns.

For anything permanent, use a 301. And for out-of-stock products, keeping the page live is usually better for both shoppers and search than redirecting it.

Temporarily Redirect Your Users with Precision!

Not sure whether a change needs a 301, a 302, or no redirect at all? Softhat IT Solutions audits redirects and technical SEO for websites and online stores across Pakistan. Explore our SEO services, or book a free strategy call to talk through your setup.

Share this article

Want to rank higher on Google?

Our SEO team audits your site, fixes what holds it back and grows your organic traffic month after month.