301 redirect generator
.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.
01
Paste the pairs
Old path, a space, then the new path or full URL. One pair per line.
02
Choose the server
Apache, Nginx, or Cloudflare Pages and Netlify.
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
| Server | Rule for /about-us/ to /about/ |
|---|---|
| Apache (.htaccess) | RedirectMatch 301 ^/about-us/?$ /about/ |
| Nginx | location = /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?
Why does the Apache output use RedirectMatch instead of Redirect?
What is a redirect chain?
Can I redirect a URL with a query string?
Where do the rules go?
Related tools
XML Sitemap Generator
A valid sitemap.xml from a list of URLs
Open itURL Slug Generator
Clean URL slugs from page titles
Open itRobots.txt Tester
Which rule allows or blocks a URL, and why
Open itLink Extractor
Every link in a page, with anchor text and rel
Open itKeyword Cannibalization Checker
Queries Google splits between your pages
Open itSERP Preview Tool
See where a title and description will be cut
Open it