307 Temporary Redirect

307
Temporary Redirect

Example HTTP Response

HTTP Response
HTTP/1.1 307 Temporary Redirect
Location: /alternative-endpoint
Common Causes
  • HTTPS redirect preserving POST data
  • Temporary URL change keeping method
  • Load balancing redirects
Technical Details

What does this mean?

Quick detour! Go this way instead, but keep doing exactly what you were doing.

Technical Definition

The server sends this response to direct the client to get the requested resource at another URI with the same method.

RFC Says

"The 307 (Temporary Redirect) status code indicates that the target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI."

Plain English:

Temporary redirect that guarantees the HTTP method stays the same. If you sent a POST request, it will remain a POST after the redirect. Use this instead of 302 in modern applications when you need to preserve the HTTP method.

Common Misinterpretation

Unlike 302 (which might change POST to GET due to historical browser behavior), 307 guarantees method preservation. This makes it the right choice for API redirects, form submissions, or any case where changing the method would break functionality. Use 303 when you explicitly want POST to become GET.

Code Snippets

Ready-to-use code for returning this HTTP status in your application:

Node.js
// Express.js
app.get('/example', (req, res) => {
  res.status(307).json({
    error: 'Temporary Redirect',
    message: 'Your error message here'
  });
});

// Native HTTP
const http = require('http');

http.createServer((req, res) => {
  res.writeHead(307, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    error: 'Temporary Redirect',
    message: 'Your error message here'
  }));
}).listen(3000);
When to Use This Code
  • Temporary redirect that must preserve the HTTP method (POST stays POST)
  • Redirecting form submissions or API calls temporarily
  • Preferred over 302 for modern applications
  • The original URL should continue to be used for future requests
SEO Handling

Indexing

Like 302, the original URL remains in the index. Google treats 307 as a temporary redirect and does not transfer ranking signals.

Crawler Behavior

Crawlers follow the redirect but expect the original URL to eventually serve content directly. They continue re-crawling the original.

Canonical URL Notes

307 is a weak canonical signal. Use only for genuinely temporary redirects. For permanent changes, use 301 or 308.

Google Notes

Google treats 307 identically to 302 for SEO purposes. The method preservation is irrelevant to crawlers using GET requests.

Commonly Confused With

307 Temporary Redirect FAQ

What causes a 307 Temporary Redirect error?

HTTPS redirect preserving POST data. Temporary URL change keeping method. Load balancing redirects.

When should I use 307 Temporary Redirect?

Temporary redirect that must preserve the HTTP method (POST stays POST). Redirecting form submissions or API calls temporarily. Preferred over 302 for modern applications. The original URL should continue to be used for future requests.