Technical Glossary

Types of Redirects

Understanding the various types of redirects is crucial for web developers, SEO specialists, and anyone involved in managing websites. Redirects play a vital role in maintaining user experience, preserving search engine rankings, and ensuring smooth navigation when content moves or changes.

This page explores the most common types of redirects. Expand any item to see implementation examples across multiple stacks (Nginx, Apache, Node.js, and Next.js). Use our Diagnostic Instrument to trace chains in real-time.

301 (Permanent Redirect)

Indicates that the requested resource has been permanently moved to a new URL. This is the most common and SEO-friendly redirect type.

Example Scenario

A website has changed its domain from http://old-domain.com to http://new-domain.com.

server {
    server_name old-domain.com;
    return 301 $scheme://new-domain.com$request_uri;
}

302 (Temporary Redirect)

Indicates that the requested resource is temporarily located at a different URL. Search engines will not update their links to point to the new URL.

Example Scenario

A page is temporarily unavailable due to maintenance, so users are redirected to a maintenance page.

location /store {
    return 302 /maintenance.html;
}

303 (See Other)

Indicates that the response to the request can be found at a different URL using a GET method, typically used after a POST request to prevent duplicate submissions.

Example Scenario

After a POST request (e.g., form submission), redirect the user to a confirmation page.

app.post('/submit-form', (req, res) => {
    // Process form data here...
    res.redirect(303, '/confirmation');
});

307 (Temporary Redirect)

Similar to 302, but guarantees that the request method and body will not be changed when reissuing the original request (e.g., a POST stays a POST).

Example Scenario

Temporarily redirect POST requests to a different processing server while maintaining the POST method and payload.

app.use('/api', (req, res) => {
    // Preserve method by forcing 307
    res.redirect(307, 'https://backup-server.com/api' + req.url);
});

308 (Permanent Redirect)

Similar to 301, but guarantees that the request method and body will not be changed when reissuing the request.

Example Scenario

Permanently redirect all API traffic from an old endpoint to a new endpoint while preserving the exact POST requests sent by legacy clients.

server {
    listen 80;
    server_name api.old-domain.com;
    return 308 https://api.new-domain.com$request_uri;
}

Meta Refresh

A client-side redirect implemented using HTML meta tags inside the document head. Generally discouraged for SEO.

Example Scenario

Redirect users after a set time period, often used for "You will be redirected in X seconds" messages.

<!DOCTYPE html>
<html>
  <head>
    <!-- The '5' indicates a 5 second delay -->
    <meta http-equiv="refresh" content="5;url=https://example.com">
  </head>
  <body>
    <p>You will be redirected in 5 seconds...</p>
  </body>
</html>

JavaScript Redirect

A client-side redirect implemented using JavaScript execution. Search engine crawlers may not execute JavaScript, making this unreliable for SEO.

Example Scenario

Redirect users based on dynamic conditions evaluated in the browser, such as user interactions, device capabilities, or timezone.

// Immediate redirect (simulates clicking a link)
window.location.href = "https://example.com";

// Immediate redirect (does NOT keep original page in session history)
window.location.replace("https://example.com");

// Delayed conditional redirect
setTimeout(() => {
    if (window.innerWidth < 768) {
       window.location.href = "https://m.example.com";
    }
}, 5000);