Web Redirect Checker
FR EN ES

Check your web redirects and HTTP responses



The 302 redirect

A 302 redirect, or temporary redirect, tells the browser and search engine crawlers that the visited page has temporarily moved to a new address. Search engines keep the original URL in their index.

Typically used for a page under maintenance, an A/B test, or a limited-time promotion.


302 Redirect with PHP

Place at the very beginning of the PHP file, before any HTML output:

<?php
header("Location: https://www.example.net/directory/page.php");
exit();
?>

By default, PHP sends a 302 code. To be explicit:

<?php
header("HTTP/1.1 302 Found");
header("Location: https://www.example.net/directory/page.php");
exit();
?>


302 Redirect with .htaccess (Apache)

Redirect a page:

Redirect /directory/old-page.html https://www.example.net/directory/new-page.html

Redirect a directory:

Redirect /old-directory https://www.example.net/new-directory

Redirect a full domain:

Redirect / https://www.example.net/

With mod_rewrite:

RewriteEngine On
RewriteRule ^old-page\.html$ /new-page.html [L,R=302]


302 Redirect with Nginx

Redirect a page:

location = /old-page.html {
    return 302 https://www.example.net/new-page.html;
}

Temporarily redirect an entire domain:

server {
    server_name example.net;
    return 302 https://www.example.net$request_uri;
}


302, 303 and 307: what's the difference?

An important technical point: when a POST request receives a 302 response, all browsers change the method to GET before following the redirect. This behaviour is non-conformant with the original RFC but is universally adopted. It can cause problems with forms and APIs.

303 See Other — Formalises this behaviour: the redirect always uses GET, regardless of the original method. This is the recommended code after processing a POST form (the PRG pattern: Post/Redirect/Get) to prevent double submission on page reload.

<?php
// After processing a POST form:
http_response_code(303);
header("Location: https://www.example.net/confirmation.php");
exit();
?>

307 Temporary Redirect — Same as 302 but the original HTTP method (POST, PUT…) is strictly preserved. Use it in REST APIs to redirect a POST request while keeping the request body.

# API endpoint redirect in .htaccess:
RewriteEngine On
RewriteRule ^api/v1/(.*)$ /api/v2/$1 [L,R=307]