Skip to content
SEO and AI search

301 Redirect Generator

Paste a list of old and new URLs and copy ready rules for Apache, Nginx, Netlify, Vercel, Cloudflare Pages or IIS, after checks for duplicates, chains and loops.

Last checked

Redirect map

Separate old and new with a space, a comma, a tab (paste two spreadsheet columns) or ->. Paths or full URLs; lines starting with # are ignored.

Moved Permanently. The usual choice for a page that has moved for good.

Server rules

6 redirects · Apache .htaccess · HTTP 301

# 6 redirects, HTTP 301. Put this above any CMS rewrite rules.
RewriteEngine On

RewriteRule ^/?old-page\.html$ /new-page/ [R=301,L]

RewriteRule ^/?blog\/2019\/hello-world$ /blog/hello-world/ [R=301,L]

RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^/?products\.php$ /shop/blue-mug/ [R=301,QSD,L]

RewriteRule ^/?about-us$ /about/ [R=301,L]

RewriteRule ^/?about\/$ /company/ [R=301,L]

RewriteCond %{HTTP_HOST} ^old-shop\.example\.com$ [NC]
RewriteRule ^/?cart$ https://shop.example.com/cart [R=301,L]
Download .htaccess

Put the rules at the top of the .htaccess in the site root, above any WordPress or framework rewrite block. RedirectMatch needs mod_alias, RewriteRule needs mod_rewrite.

Checks

0 to fix, 1 to check

  • CheckLine 4: chain /about-us → /about/ → /company/ (2 hops). Flatten to go straight to /company/.

Site-wide redirects

www
Trailing slash

Uses the redirect type chosen above (HTTP 301).

RewriteEngine On

# HTTPS and www.example.com → example.com in one hop
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
  • CheckBehind a load balancer or CDN that ends TLS, the server sees plain HTTP and the HTTPS rule loops. Check X-Forwarded-Proto or redirect at the CDN instead.

How to use it

  1. Paste your redirect map, one pair per line: the old URL first, then the new one. Two columns copied from a spreadsheet work as they are.
  2. Pick the status code. Use 301 or 308 for pages that have moved for good, 302 or 307 for a temporary move.
  3. Choose your server or host and read the checks. Press Flatten chains so every old URL goes straight to its final address.
  4. Copy or download the rules and add them to your config. For HTTPS, www or trailing slash rules across the whole site, use Site-wide redirects below.
  5. After deploying, request a few old URLs with curl -I and check the status line and the Location header.

What it checks and why

A redirect map is usually a spreadsheet: old URLs in one column, new URLs in the other. Turning it into server rules by hand is where mistakes creep in: a regex dot left unescaped, a query string that Redirect cannot see, a percent sign that Apache reads as a back-reference. The generator writes the rules from the list and applies each server's own syntax, so the same map works on Apache, Nginx, Netlify, Vercel, Cloudflare Pages and IIS.

Google treats 301 and 308 as permanent: the new URL is the strong canonical signal and replaces the old one in results. 302 and 307 are temporary, so the old URL may stay indexed. Google follows up to 10 hops in a chain, but every hop costs a request and time, so a rule should point straight at the final URL. That is what Flatten chains does.

Apache's plain Redirect directive matches a path prefix: Redirect 301 /blog /news also sends /blog/post to /news/post, and Redirect 301 /blog /blog/ loops forever because /blog/ starts with /blog. The generator writes RedirectMatch 301 ^/blog$ /blog/ instead, which matches the exact path only, and switches every rule to mod_rewrite when one of them needs a query string or a domain, so mod_alias and mod_rewrite are never mixed. In RewriteRule the dollar and percent signs in the target are escaped and NE is added, so an encoded target such as %20 is not encoded twice.

Nginx's location cannot see the query string, so a source like /product.php?id=42 is matched against $request_uri instead. For long lists a map block is faster and easier to keep than hundreds of location blocks.

Specs and sources

Limits

  • Rules match exact URLs. Patterns such as /blog/* → /news/:splat are not generated; write those by hand or use the site-wide rules.
  • A query-string source matches only that exact query, in that order. Netlify matches query keys as placeholders, not fixed values, and Cloudflare Pages _redirects cannot match a fixed query, so those rules are left out with a note. Cloudflare Pages _redirects cannot match a domain either; use Bulk Redirects.
  • IIS URL Rewrite has no 308 type, so 308 falls back to 301 there.
  • The tool cannot see your live server. Existing rules, a CMS, a CDN or a proxy can run first or change the result, so test the old URLs after deploying.

Questions

How do I redirect a page with .htaccess?
Add RedirectMatch 301 ^/old-page$ /new-page to the .htaccess file in the site root, above any CMS rewrite rules. The ^ and $ make it an exact match; a plain Redirect 301 /old-page /new-page would also redirect everything below /old-page/. For an old URL with a query string or on another domain, use mod_rewrite: a RewriteCond for the query or host, then RewriteRule with [R=301,L]. The generator picks the right form for you.
How do I do a 301 redirect in Nginx?
Inside the server block, add location = /old-page { return 301 /new-page; }. The = makes it an exact match. For hundreds of URLs, a map block in the http context and one if ($redirect_uri) { return 301 $redirect_uri; } in the server block is faster and easier to maintain.
What is the difference between a 301 and a 302 redirect?
301 says the page has moved for good; Google moves the old URL's signals to the new one and shows the new URL in results. 302 says the move is temporary, so the old URL can stay indexed. 308 and 307 are the same pair, but browsers keep the request method and body, which matters for forms and APIs.
Do redirect chains hurt SEO?
Google follows up to 10 hops, but each hop is another request that slows users and crawlers, and long chains can stop being followed. Point every old URL straight at its final address. The checks list every chain and Flatten chains rewrites them.
How do I redirect HTTP to HTTPS and www to non-www?
Use Site-wide redirects: enter your domain, tick HTTP → HTTPS and pick www → non-www. The Apache output does both in one hop with RewriteCond %{HTTPS} off [OR] and a host condition; the Nginx output uses separate server blocks that return 301 to https://your-domain.
Why does my redirect loop?
Usually one of three things: the new URL still matches the old rule (Redirect 301 /blog /blog/ on Apache, or /a to /a?ref=1 anywhere, since a rule without a query matches every query), the server compares paths without case (IIS by default, so /About to /about loops), or an HTTPS rule runs behind a CDN that ends TLS and sends plain HTTP to the server. The checks flag the first two.
How long should I keep 301 redirects?
Google's site move guide says to keep them for at least a year. Keep them longer if old links still bring visitors; a redirect costs almost nothing to leave in place.