301 Redirect Generator (.htaccess, Nginx, IIS)
Turn old-to-new URL lists into server redirect rules, with chain and loop checks.
One per line: old new, optionally with a status (/a /b 302). Separate with a space, tab, comma or →. End a folder with * to move everything under it (/blog/* /news/*). Mark removed pages with 410. Lines starting with # are ignored.
Site migration: match two URL lists by slug
Paste the old site's URLs and the new site's URLs (for example from both sitemaps). Each old URL is paired with the new URL whose last path segment is most similar; check the proposals, then add them to the list.
| Use | Old URL | New URL | Match |
|---|
Server and options
Site-wide rules: HTTPS, www, trailing slash, .html, domain move
Checks
No problems found.
About the 301 Redirect Generator (.htaccess, Nginx, IIS)
Moving pages, renaming a folder or migrating a whole site? Paste the old and new URLs — one pair per line, from a spreadsheet or a CSV — and get ready-to-paste redirect rules for Apache .htaccess (Redirect, RedirectMatch or mod_rewrite), Nginx (location blocks or a map), IIS web.config, Cloudflare Pages and Netlify _redirects, or zero-delay meta refresh pages for static hosting.
Before anything is written the list is checked: invalid addresses, duplicates with different targets, redirects to themselves, chains (A → B → C, fixed in one click) and loops, #fragments that never reach the server, query strings a format cannot match, many URLs dumped on the home page, and Cloudflare Pages' limits. Ready-made site-wide rules cover HTTPS, www or non-www, trailing slashes, removing .html and moving to a new domain. A migration helper pairs two URL lists by slug similarity.
How to use it
- Paste the redirects, one per line:
old new, optionally with a status (/a /b 302). End a folder with*(/blog/* /news/*); mark removed pages410. Or use Load CSV, Add, or Site migration to match two URL lists. - Choose the server under Write rules for, and the default status (301 for permanent moves).
- Set the options: pass query strings on, match with or without a trailing slash, ignore case, or treat old URLs as regular expressions.
- Optionally enter the site's canonical address and add site-wide rules (HTTPS, www, trailing slash, .html, domain move).
- Fix anything under Checks — Fix chains points every redirect straight at its final URL — then Copy or Download the rules and test them on a staging copy.
Examples
/old-page.html /new-page/
RewriteRule ^/?old-page\.html$ /new-page/ [R=301,L]
The ^/? makes the same rule work in .htaccess (where the leading slash is removed) and in the server configuration.
/blog/* /news/*
rewrite ^/blog/(.*)$ /news/$1 permanent;
/product.php?id=12 /shop/blue-shirt/
<match url="^product\.php$" ignoreCase="false" />
<conditions><add input="{QUERY_STRING}" pattern="^id=12$" /></conditions>/a /b /b /c
Chain: the new URL is redirected again by line 2 → Fix chains rewrites line 1 as /a /c
Which status code to use
Google treats 301 and 308 (and an instant meta refresh) as permanent: the new URL becomes the canonical one. 302, 303 and 307 are temporary, and Google does not use them as a signal that the target should be canonical (Redirects and Google Search). Use 410 for pages that are gone for good with no replacement. Google's site-move guide adds: keep redirects for as long as possible — generally at least a year — and don't send many old URLs to one irrelevant page such as the home page, which can be treated as a soft 404 (Site moves with URL changes).
How each format behaves
- Apache Redirect matches the start of the path:
/oldalso redirects/old/pageto/new/page, and the first matching line wins, so specific lines are written first. The visitor's query string is passed on. - Apache RedirectMatch and mod_rewrite use regular expressions anchored with
^…$, so only the exact URL matches; mod_rewrite can also match query strings and drop them (QSD). - Nginx:
location =for exact URLs,rewrite … permanentfor folders,$request_urifor query strings; amap(in the http block) scales to thousands of redirects. - IIS URL Rewrite supports 301, 302, 303 and 307 but not 308, and matches case-insensitively unless told otherwise.
- Cloudflare Pages
_redirects: up to 2,000 static and 100 dynamic redirects, 1,000 characters per line, no query-string matching and no domain-level rules (Cloudflare docs). - Netlify
_redirects: 301 is the default, 307 is not supported (use 302), and!forces a redirect over a file that still exists.
Chains, loops and other checks
A chain is a redirect to a URL that is itself redirected. Googlebot follows up to 10 hops, but Google advises pointing straight at the final destination, and every hop slows visitors down — Fix chains does this for the whole list. A loop (A → B → A, or a page redirected to itself once trailing-slash or case matching is applied) makes browsers stop with "too many redirects". The checks also flag #fragments in old URLs (browsers never send them to the server), duplicate old URLs with different targets, regex characters typed in list mode, unescaped dots and missing capture groups in regex mode, and formats that cannot express a rule.
Limitations
- Generated rules are text; test them on a staging copy (Apache
apachectl configtest,nginx -t) and check the results with the redirect checker before going live. - Wildcards are supported at the end of a path (
/folder/*). For anything more complex, use regular-expression mode (Apache, Nginx and IIS only). - Query-string redirects match one exact query string (same parameters in the same order).
- The site migration helper compares the last path segment of each URL; always review its proposals.
Privacy
Everything happens in your browser. What you enter or open here is not uploaded or stored by MySmartCoPilot.
Frequently asked questions
Where do I put the .htaccess rules?
In the .htaccess file in your site's root folder (create it if needed; it must be named exactly .htaccess). The download is named htaccess.txt because browsers do not reliably save files whose names start with a dot — rename it on the server. Rules can also go in the <VirtualHost> block, where they run faster.
Should I use Redirect, RedirectMatch or mod_rewrite on Apache?
Redirect is simplest but matches path prefixes and cannot match query strings. RedirectMatch matches exact URLs with regular expressions. mod_rewrite can do both plus query strings and dropping them, and is the best choice when you also need site-wide HTTPS or www rules.
Does a 301 redirect keep my search rankings?
Google treats a 301 as a strong signal that the new URL should replace the old one in its index, so signals move to the new URL over time. Redirect each page to its closest equivalent and keep the redirects in place for at least a year, as Google advises.
Can I redirect URLs with a #fragment?
No. The part after # never leaves the browser, so the server cannot see it. Redirect the page without the fragment; a fragment in the new URL (/new#section) is fine.
Is my URL list uploaded?
No. Parsing, checking and generating all happen in your browser.