Skip to content

Redirect guides

Everything about redirects and status codes, with examples you can copy.

Status codes

  • 301 vs. 302 redirect

    A 301 says "this URL has moved for good", a 302 says "look over there for now". The difference sounds small, but it affects which URL Google indexes, how long browsers remember the redirect and how easy it is to undo.

  • 307 vs. 308 redirect

    307 and 308 are the strict siblings of 302 and 301: they guarantee that a POST stays a POST. Here is what that means in practice, why you often see a 307 that your server never sent, and when a 308 is the better permanent redirect.

  • 301 redirect

    A 301 redirect permanently sends visitors and search engines from an old URL to a new one. It is the standard tool for relaunches, domain moves and URL changes. Here is how it works, how to set it up and how to avoid the classic mistakes.

  • Meta refresh and JavaScript redirects

    Not every redirect happens on the server. A meta refresh tag or a line of JavaScript can also send visitors to another URL. Here is how these client-side redirects work, how Google handles them and why they should only be your fallback.

Servers & platforms

  • .htaccess redirects on Apache

    Everything you need to redirect pages and whole domains with .htaccess on Apache: mod_alias vs. mod_rewrite, copy-ready rules for the common cases, and how to avoid loops and chains.

  • nginx redirects

    Copy-ready nginx configuration for 301 redirects: single pages, patterns, whole domains, HTTPS and www in a single hop, and hundreds of URLs with map.

  • Redirects on Cloudflare

    Cloudflare can answer redirects at the edge before a request ever reaches your server. Here is how Single Redirects, Bulk Redirects and Always Use HTTPS work, and how to keep them from fighting with your origin.

  • Redirects in WordPress

    WordPress gives you several ways to redirect a URL: a plugin, a rule in .htaccess or a few lines of PHP. This guide shows when to use which, and how to avoid the typical pitfalls with caching and HTTPS.

  • Redirects in Next.js

    Next.js has four places where you can redirect: the config file, middleware, server code in the App Router and the trailingSlash option. Each one sends different status codes by default, so it pays to know which is which.

  • Redirects on Vercel and Netlify

    On Vercel and Netlify you don't touch a web server config. Redirects live in a file in your repository or in the dashboard, and the platform's edge network sends them. Here is how both work and where they differ.

  • Redirects on Microsoft IIS

    IIS gives you two ways to redirect: the built-in HTTP Redirect feature and the URL Rewrite module. Here is when to use which, with web.config examples you can copy.

Use cases

  • Redirect HTTP to HTTPS

    Every HTTP URL on your site should end up on its HTTPS version in exactly one permanent redirect. Here is how to set that up, secure it with HSTS and verify the result.

  • www to non-www redirect (and vice versa)

    www.example.com and example.com are two different hosts. Pick one, redirect the other to it permanently and make sure everything else on your site agrees.

  • Domain migration checklist

    Moving a website to a new domain is manageable if every old URL redirects to its exact counterpart. This checklist walks you through before, during and after the move.

  • Redirect chains and redirect loops

    Every extra redirect hop costs time, and a loop makes a page completely unreachable. Here is how chains and loops arise, how to find them and how to get rid of them.

More free tools

  • Bulk checker

    Check up to 20 URLs at once, e.g. your redirect map after a domain migration. Export as CSV.

  • Header checker

    See all HTTP response headers of every hop, including Location, Cache-Control and HSTS.

  • .htaccess redirect generator

    Generate Apache .htaccess rules for single pages, HTTPS and www redirects.

  • nginx redirect generator

    Generate nginx server blocks and return rules for your redirects.

  • HTTP status codes

    All HTTP status codes explained, with notes on how Google treats them.

  • JSON API

    Check redirects from your scripts and CI pipelines with a simple JSON API.