HTTP 302 Found

The resource you requested is temporarily located at a different URL. Unlike a 301 permanent redirect, the server is telling you that the original URL is still valid and future requests should continue using it.

What Is HTTP 302 Found?

HTTP 302 Found is a redirection status code indicating that the requested resource temporarily resides at a different URL. The server includes the temporary URL in the Location header, and browsers automatically follow the redirect. Unlike 301 Moved Permanently, a 302 tells search engines and clients that the original URL remains the authoritative address and should continue to be used for future requests.

The 302 status code has a complicated history. It was originally defined in HTTP/1.0 as "Moved Temporarily" and was intended to preserve the HTTP method during redirection. However, most browsers implemented it by changing POST requests to GET requests after the redirect. This unintended behavior became so widespread that when HTTP/1.1 was finalized, the specification was updated to acknowledge the method-changing behavior. To address this ambiguity, HTTP/1.1 introduced 307 Temporary Redirect, which strictly preserves the original HTTP method.

Today, 302 is widely used for scenarios where a resource is temporarily available at a different URL. Common use cases include redirecting unauthenticated users to a login page, routing users to geographically appropriate content, serving maintenance pages during deployments, and implementing A/B tests. For new projects, consider using 307 when method preservation matters, and reserve 302 for simple GET-to-GET temporary redirects where the historical method-changing behavior is acceptable.

Common Causes

Temporary Maintenance Page

A page is temporarily unavailable and users are redirected to a maintenance page. The 302 tells search engines to keep the original URL indexed because the move is not permanent.

A/B Testing Redirect

Users are temporarily redirected to different page variants for A/B testing. The 302 ensures search engines do not treat the test variant as the canonical URL.

Login Redirect

An unauthenticated user tries to access a protected page and is temporarily redirected to the login page. After authentication, they return to the original URL.

Geolocation-Based Routing

Users are redirected to region-specific content based on their IP address or browser locale. The redirect is temporary because the same URL serves different users differently.

How to Fix

Consider Using 307 Instead

HTTP 302 historically allowed browsers to change POST to GET during redirection. If preserving the HTTP method is important, use 307 Temporary Redirect which strictly maintains the original method.

Do Not Use 302 for Permanent Moves

If the URL change is permanent, use 301 instead. Using 302 for permanent moves prevents search engines from transferring ranking signals to the new URL, which hurts your SEO.

Set Cache-Control Headers

Temporary redirects should include Cache-Control: no-cache or a short max-age to prevent browsers from caching the redirect and missing when the resource returns to its original location.

Track Redirect Performance

Monitor 302 redirects in your analytics to ensure they are not negatively impacting user experience. Each redirect adds latency, so minimize their use in critical user flows.

Code Examples

Express.js

// Express.js — temporary redirects
const express = require('express');
const app = express();

// Redirect to login page for unauthenticated users
app.get('/dashboard', (req, res, next) => {
  if (!req.session.userId) {
    // 302 — temporary redirect to login
    return res.redirect(302, '/login?returnTo=/dashboard');
  }
  next();
});

// A/B testing redirect
app.get('/pricing', (req, res, next) => {
  const variant = Math.random() < 0.5 ? 'a' : 'b';
  if (variant === 'b') {
    return res.redirect(302, '/pricing-v2');
  }
  next();
});

// Geolocation-based routing
app.get('/store', (req, res) => {
  const country = req.headers['cf-ipcountry'] || 'US';
  if (country === 'GB') {
    return res.redirect(302, '/store/uk');
  }
  res.redirect(302, '/store/us');
});

Flask (Python)

# Flask — temporary redirects
from flask import Flask, redirect, request, session, url_for

app = Flask(__name__)

# Redirect to login for unauthenticated users
@app.route('/dashboard')
def dashboard():
    if 'user_id' not in session:
        return redirect(url_for('login', returnTo='/dashboard'), code=302)
    return render_template('dashboard.html')

# A/B testing redirect
import random

@app.route('/pricing')
def pricing():
    if random.random() < 0.5:
        return redirect('/pricing-v2', code=302)
    return render_template('pricing.html')

# Geolocation-based routing
@app.route('/store')
def store():
    country = request.headers.get('CF-IPCountry', 'US')
    if country == 'GB':
        return redirect('/store/uk', code=302)
    return redirect('/store/us', code=302)

Frequently Asked Questions

What is the difference between 302 and 307?

Both are temporary redirects, but 302 may change the HTTP method from POST to GET during redirection. 307 strictly preserves the original HTTP method. Use 307 when maintaining the method is important, such as form submissions or API calls.

Does a 302 redirect pass SEO value?

Typically, no. Search engines treat 302 as temporary and do not transfer ranking signals to the new URL. They continue to index the original URL. If you want to pass SEO value, use a 301 permanent redirect instead.

When should I use 302 instead of 301?

Use 302 when the URL change is genuinely temporary. Examples include maintenance redirects, A/B testing, login page redirects, and geo-based routing. If the change is permanent, always use 301 to preserve SEO value.

Can I redirect POST requests with 302?

You can, but browsers will likely change the POST to a GET. If you need to redirect a POST and keep it as a POST, use 307 Temporary Redirect instead. This is a well-known quirk of 302 dating back to early browser implementations.

How does 302 affect Google indexing?

Google will continue to index the original URL when it encounters a 302. If the redirect stays in place for a very long time, Google may eventually treat it as a 301 and index the new URL instead, but this behavior is not guaranteed.

Monitor Your APIs & Services

Get instant alerts when your endpoints go down. 60-second checks, free forever.

Start Monitoring Free →