Skip to content
Koit Academy

301 redirect generator

Your details

The details filled in are an example. Everything runs in this browser; nothing you type is sent anywhere or stored.

.htaccess

4 rules for Apache.

RedirectMatch 301 ^/old-services/roofing\.html/?$ /roofing/
RedirectMatch 301 ^/blog/spring-offer/?$ /offers/
RedirectMatch 301 ^/about-us/?$ /about/
RedirectMatch 301 ^/contact\.php/?$ https://www.example.com/contact/
  • Note: Put the lines near the top of the .htaccess file in the site root (a download is saved as htaccess.txt, because browsers will not save a name starting with a dot). Each rule matches the old path with or without a trailing slash, and nothing longer.

How to use it · free, no signup

How to use the 301 Redirect Generator

Paste old and new paths, one pair per line, to get exact-match redirect rules for Apache, Nginx or Cloudflare Pages and Netlify, checked for chains, loops and duplicates. Runs in your browser.

  1. 01

    Paste the pairs

    Old path, a space, then the new path or full URL. One pair per line.

  2. 02

    Choose the server

    Apache, Nginx, or Cloudflare Pages and Netlify.

  3. 03

    Check, then download

    Fix any chain or loop it reports, then add the rules to your server.

Permanent or temporary

A redirect sends a request for one address to another, and its status code says why. Google’s guide to redirects treats 301 and 308 as permanent, a signal that the new address should be the one shown in results, and 302, 303 and 307 as temporary, after which the old address generally stays. It recommends a server-side permanent redirect whenever a page has moved for good.

The same rule, three ways

ServerRule for /about-us/ to /about/
Apache (.htaccess)RedirectMatch 301 ^/about-us/?$ /about/
Nginxlocation = /about-us/ { return 301 /about/; }
Cloudflare Pages or Netlify/about-us/ /about/ 301

Every rule is an exact match. The Apache version uses RedirectMatch with an anchored pattern because, as Apache’s mod_alias documentation explains, the simpler Redirect directive matches any request beginning with the old path, so a rule for /old would also catch /older.

Chains, loops and duplicates

  • Chains. /a to /b and /b to /c means two hops for every visit to /a. The generator reports the chain so /a can point straight at /c.
  • Loops. /a to /b to /a never arrives anywhere. Browsers stop with an error and crawlers give up.
  • Duplicates. Two rules for the same old path: only the first can ever run, so the second is dropped and reported.
  • Query strings. A source like /shop?id=4 cannot be matched by these rules and is left out with an explanation.

After the rules are live

Update internal links to point at the new addresses directly, rather than relying on the redirect, and update the sitemap so it lists only final addresses; the XML sitemap generator rebuilds one from a list. If the move came with new page names, the URL slug generator keeps the new slugs consistent.

Published by Koit Academy. Who runs it, how it is paid and how its tools are checked.

Questions

What people ask about the 301 Redirect Generator

What is the difference between a 301 and a 302 redirect?
A 301 says the page has moved for good, and Google treats the new address as the one to index. A 302 says the move is temporary, so the old address tends to stay in results.
Why does the Apache output use RedirectMatch instead of Redirect?
Apache’s Redirect directive matches a path prefix, so a rule for /old also catches /old-news. RedirectMatch with an anchored pattern matches the old path exactly.
What is a redirect chain?
A redirect that leads to another redirect, such as /a to /b to /c. Each hop is another request; pointing /a straight at /c is faster and cleaner.
Can I redirect a URL with a query string?
Not with these rules, which match the path only. A redirect that depends on ?id=4 needs a rewrite rule written for your server.
Where do the rules go?
For Apache, near the top of .htaccess in the site root. For Nginx, inside the site’s server block. For Cloudflare Pages or Netlify, in a file called _redirects in the published folder.