htaccess Redirect Generator
Turn old and new URLs into 301 redirect rules for Apache, Nginx, IIS, Cloudflare, Netlify, Vercel, Next.js, or WordPress, with chains fixed and loops caught.
- Free
- No sign-up
- Runs in your browser
- Updated
Your rules
Checks
Test a URL
Follows your redirects hop by hop, the way a browser or Googlebot would.
How to use the htaccess Redirect Generator
-
List your redirects
Enter one redirect per line: the old URL, then the new URL. Paste two columns from a spreadsheet or upload a CSV.
-
Set the options
Choose the status code, what happens to query strings, and how trailing slashes and case are matched.
-
Add site-wide rules
Optionally enter your site's address to redirect HTTP to HTTPS and other hostnames in one hop.
-
Pick your platform
Choose Apache, Nginx, IIS, Cloudflare, Netlify, Vercel, Next.js, or a WordPress plugin format.
-
Check, test, and copy
Fix anything in the checks, test a few old URLs, then copy or download the rules.
Example: .htaccess rules for a site restructure
Five redirects, including a chain, a query-string URL, and a folder move, turned into Apache rules.
/about-us.html /about/
/services/web-design/ /services/websites/
/services/websites/ /web-design-services/
/product.php?id=42 /shop/trail-shoes/
/blog/* /news/*
# Redirects
RewriteEngine On
# /about-us.html
RewriteRule ^about-us.html$ /about/ [R=301,L,NE]
# /services/web-design/
RewriteRule ^services/web-design/?$ /web-design-services/ [R=301,L,NE]
# /services/websites/
RewriteRule ^services/websites/?$ /web-design-services/ [R=301,L,NE]
# /product.php?id=42
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^product.php$ /shop/trail-shoes/ [R=301,L,NE,QSD]
# /blog/*
RewriteRule ^blog/(.*)$ /news/$1 [R=301,L,NE]
/services/web-design/ pointed to a page that redirects again, so it now goes straight to /web-design-services/. The product URL only matches id=42, and its old query string is dropped.
This htaccess redirect generator turns a list of old and new URLs into ready-to-use redirect rules for Apache, Nginx, IIS, Cloudflare, Netlify, Vercel, Next.js, and the main WordPress redirect plugins. Paste one redirect per line, or two columns from a spreadsheet, and pick your platform. The generator finds conflicts, loops, and chains before they reach your site, fixes chains automatically, and lets you trace any URL hop by hop. Everything runs in your browser.
How to generate redirect rules
- List your redirects, one per line: the old URL, then the new URL. Paths such as
/old-page/and full URLs both work. End both with*to move a whole folder. - Choose your options: the status code, whether query strings are passed on, and whether old URLs match with or without a trailing slash.
- Pick your server or platform. The rules update instantly, with notes on where to paste them.
- Read the checks and test a URL, then copy or download the rules.

301, 302, 307, or 308?
Google treats 301 and 308 as permanent redirects: a strong signal that the new URL should be indexed instead of the old one. 302 and 307 are temporary, so Google may keep the old URL in its index. Use a 301 for almost every page move, which is why this 301 redirect generator uses it by default.
| Code | Meaning | Use it for |
|---|---|---|
| 301 | Moved permanently | Page moves, site migrations, and URL changes. The safe default. |
| 308 | Permanent redirect | The same as 301 for Google, but the request method is kept. Not available in IIS. |
| 302 | Found (temporary) | Short-term moves, such as a promotion or maintenance page. |
| 307 | Temporary redirect | A temporary move that keeps the request method. |
Put the code at the end of a line, such as /sale/ /summer-sale/ 302, to override the default for that redirect only.
Bulk redirects from a spreadsheet
Most redirect maps start in a spreadsheet: an export of old URLs from a crawl or Search Console, with the new URL typed next to each one. Copy the two columns and paste them in, or upload the CSV. A header row is skipped automatically, full URLs and paths can be mixed, and lines that can’t be read are listed in the checks with their line numbers. The redirect generator handles tens of thousands of bulk redirects in a second or two, and the Spreadsheet (CSV) format gives you a clean copy of the final map, with chains already resolved.
When not to redirect
Redirects are for content that has moved. If a page is gone for good and has no close replacement, let it return a 404 or 410 status instead: Google treats a redirect to an unrelated page, such as the home page, as a soft 404 anyway. The generator rejects 410 and 451 lines for that reason, since they need a different setup on your server.
.htaccess redirects done right
Most htaccess generators write Redirect 301 /old /new. That directive is a prefix match: it also redirects /old/anything and appends the rest of the path, which surprises many site owners. It can’t match query strings either. This generator uses mod_rewrite for every rule instead, so each redirect matches exactly what you listed:
RewriteEngine On
# /old-page/
RewriteRule ^old-page/?$ /new-page/ [R=301,L,NE]
# /product.php?id=42
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^product\.php$ /shop/trail-shoes/ [R=301,L,NE,QSD]
The QSD flag drops the old query string once it has been matched, and NE stops Apache from encoding the new URL twice. Using one module also avoids a classic problem: in .htaccess, Apache runs Redirect lines before RewriteRule lines, whatever order you write them in. Place the rules above any WordPress or other rewrite block, because the first matching rule wins. Exact matching is the main difference between this htaccess redirect generator and tools that only write Redirect lines.
Nginx redirects
For Nginx, each path gets an exact location = block with a return, which is the fastest and safest way to redirect a single URL. Rules for URLs with a query string use a check on $request_uri at the server level, so PHP and other handlers for that path keep working for other URLs. For more than 25 redirects, the generator switches to a map, which goes in the http block and scales to tens of thousands of URLs. HTTPS and www redirects use separate server blocks, as Nginx recommends.
Other platforms
- IIS: rules go in web.config and need the URL Rewrite module. IIS doesn’t support 308, so the generator uses 301.
- Cloudflare Bulk Redirects: a CSV list with no header row. Bulk Redirects can’t match query strings, and every source needs its domain.
- Netlify: a
_redirectsfile. Netlify matches with or without a trailing slash automatically, and the!forces a redirect even if a file still exists at the old URL. - Vercel and Next.js: redirect objects for vercel.json or next.config.js. Vercel allows 2,048 redirects in vercel.json; larger lists need Vercel’s Bulk Redirects.
- WordPress: import files for the Redirection plugin, Rank Math PRO, and Yoast SEO Premium.
Redirect chains and loops
A chain is a redirect that leads to another redirect, such as A to B to C. Google follows up to 10 redirects in a row, but recommends sending visitors straight to the final URL, and every extra hop slows the page down. With Fix chains turned on, the generator rewrites A to go directly to C.

A loop sends visitors in a circle, such as A to B and B back to A, and the browser eventually shows an error. Loops are flagged and left out, along with redirects that point to themselves. A common cause is a trailing slash: with slashes ignored, /contact and /contact/ are the same URL.
Query strings and trailing slashes
By default, query strings on old URLs are passed on, so tracking parameters such as ?utm_source=newsletter survive the redirect. Choose Remove them if the new site uses different parameters. When the old URL itself includes a query string, such as /product.php?id=42, the rule only matches that exact query, and the old query is dropped.
Old URLs match with or without a trailing slash, unless they end in a file name such as .html. Turn this off if you need to redirect between the two forms of the same URL.
Site moves: HTTPS, www, and new domains
Under Site-wide rules, enter your site’s address and choose to redirect HTTP to HTTPS and every other hostname to it. The generator combines them into one rule, so http://example.com/page reaches https://www.example.com/page in a single hop, and it points your specific redirects at the final address too. Google recommends keeping redirects in place for at least a year after a site move, and warns against sending many old URLs to the home page, which it may treat as soft 404s. Send each old page to its closest match instead.
After you publish your redirects
Test a few old URLs in your browser, update internal links and your XML sitemap to point straight to the new URLs, and keep a copy of the redirect map, which the Spreadsheet (CSV) format gives you. Then make sure the new pages aren’t blocked with the robots.txt Tester, update language versions with the hreflang Tag Generator, and check how the new pages appear in search with the SERP Snippet Preview.
htaccess Redirect Generator FAQ
How do I redirect one page in .htaccess?
Use mod_rewrite: RewriteEngine On, then RewriteRule ^old-page/?$ /new-page/ [R=301,L]. The generator writes these lines for every redirect in your list.
Should I use 301 or 302?
Use 301 (or 308) when a page has moved permanently. 302 and 307 are temporary, so Google may keep the old URL indexed.
Why does Redirect 301 /old also redirect /old/page?
Apache's Redirect directive is a prefix match: it redirects everything that starts with the path and appends the rest. Use RewriteRule with ^ and $ for exact matches.
How do I redirect a URL with a query string?
Match the query with RewriteCond %{QUERY_STRING} in Apache, or check $request_uri in Nginx. The generator does this when the old URL includes ?.
What is a redirect chain?
A redirect that leads to another redirect. Google follows up to 10, but recommends pointing every old URL straight to its final destination.
How long should I keep redirects?
Google recommends keeping redirects for as long as possible after a site move, generally at least a year.
Related tools
robots.txt Tester
Test any URL against your robots.txt for Googlebot, Bingbot, AI crawlers, and more, with the exact line that decides each result.
hreflang Tag Generator
Create hreflang tags, HTTP headers, or an XML sitemap for one page or thousands, with every code and URL checked against Google's rules.
SERP Snippet Preview
See your title and meta description as Google shows them on desktop and mobile, with pixel-accurate cut-offs and title checks.
AI Crawler robots.txt Generator
Block AI training crawlers, AI search bots, or both in robots.txt, keep your existing rules, and test any URL before you upload.
Heading Structure Checker
Check a page's H1–H6 outline from HTML or a pasted document: skipped levels, missing or empty headings, and keyword use.
JSON-LD Validator
Validate JSON-LD against schema.org and Google's rich result rules, find exact syntax errors, and auto-fix common mistakes.