Redirect Generator
Converts one list of source paths, targets, and 301, 302, 307, 308, or 410 codes into redirect rules for eight server and hosting formats. Regex patterns for .htaccess and web.config lose their leading slash because per-directory rules never see it, and rules a format cannot express, such as 308 on IIS or 410 on Netlify, are flagged rather than dropped.
This tool sends nothing over the network. Everything you enter is processed on your device and never reaches our servers.
Documentation
A redirect generator turns a list of old paths and their new locations into the configuration each server or host expects. A redirect is an HTTP response with a 3xx status code and a Location header. The same list of moves is written differently for Apache .htaccess, Nginx, IIS web.config, PHP, JavaScript, an HTML meta refresh, Cloudflare Pages, and Netlify, and each format has its own matching rules and gaps.
The status code is the main decision. 301 and 308 mark a permanent move, and Google treats the target as the canonical URL; 302 and 307 mark a temporary one, so the old URL stays in search results. 307 and 308 also require the client to repeat the request with the same method and body, which matters for form posts and API calls, while a client receiving 301 or 302 may switch a POST to a GET. 410 Gone takes no target: it says the page was removed on purpose rather than lost.
Matching differs by format. Apache's Redirect directive matches whole path segments by prefix, so a rule for /old also sends /old/page to /new/page, and a rule for the site root is written as an anchored RedirectMatch so it does not catch every URL on the site. Nginx location = blocks, IIS rules, PHP, JavaScript, Cloudflare, and Netlify match the exact path. The trailing-slash option makes every format accept /old and /old/ alike: Nginx and IIS get /? in the pattern, PHP and JavaScript trim the slash before comparing, Cloudflare gets a second line because it does not normalize slashes, and Netlify needs nothing because it already ignores them.
In regex mode the source is a pattern, and $1 to $9 in the target refer to its capture groups. Rules in .htaccess and web.config see the path without its leading slash, so a pattern written as ^/archive/ becomes ^archive/; Nginx patterns that contain braces or semicolons are quoted, IIS captures become {R:1}, and PHP and JavaScript use preg_match and RegExp. Meta refresh, Cloudflare, and Netlify have no regex matching, so pattern rules are listed as skipped for those formats.
The query string of the incoming request is kept. Apache, IIS, and Netlify pass it on by default, and the generated Nginx, PHP, and JavaScript code appends it unless the target already carries its own. Format limits appear beside the output: IIS URL Rewrite has no 308 and sends those rules as 301, Netlify documents only 301 and 302, Cloudflare and Netlify cannot return 410, and a Cloudflare _redirects file holds at most 2,000 static and 100 dynamic rules. JavaScript and meta refresh redirects send no status code at all; Google reads an instant meta refresh as permanent and sees a JavaScript redirect only if rendering succeeds. Settings holds the output format, comment annotations, regex mode, and the trailing-slash option, and rules travel in and out as a three-column CSV of source, target, and status.
A 301 rule from /old-page to /new-page becomes Redirect permanent /old-page /new-page in .htaccess and location = /old-page { return 301 /new-page$is_args$args; } in Nginx, so a request for /old-page?utm_source=mail arrives at /new-page?utm_source=mail. In regex mode, the pattern ^/archive/(\d{4})/(.+)$ with the target /news/$1/$2 becomes RewriteRule ^archive/(\d{4})/(.+)$ /news/$1/$2 [R=301,L] in .htaccess and a web.config rule matching ^archive/(\d{4})/(.+)$ with the target /news/{R:1}/{R:2}, and a request for /archive/2023/launch lands on /news/2023/launch.
Redirect rules manage URL changes during website migrations, content restructuring, and domain consolidation. Each scenario below depends on choosing the right status code and on the target server honoring it.
- Site Migration: Map hundreds of old URLs to new locations when moving from one CMS to another. A CSV export from a crawl tool, with source, target, and status columns, loads every changed path at once, and the same list can be written for whichever server the new site runs on.
- Domain Consolidation: Redirect traffic from multiple legacy domains to a single canonical domain. A 301 rule for each old path, pointing to the equivalent page as an absolute URL on the primary domain, carries search engine ranking signals across.
- Content Restructuring: Reorganize a blog or documentation site by moving pages into new category folders. Rules that map old flat URLs like
/post-titleto nested paths like/category/post-titlekeep organic search traffic from landing on 404 pages. - Product Sunset: Mark discontinued product pages as 410 Gone to signal search engines that the content has been intentionally removed rather than accidentally lost. Combine 410 rules with 301 rules that redirect related product pages to a category or alternative product page.
- Multi-Platform Deployment: Generate the same set of redirects in different formats for staging versus production environments. A development server running Nginx and a production CDN on Cloudflare Pages can both receive the correct syntax from the same source rules.
- A/B Testing Cleanup: Temporary 302 redirects from a finished A/B test can be replaced with permanent 301 rules pointing to the winning page variant, so search engines consolidate signals on that page across every server configuration.
- Regex Pattern Redirects: Redirect entire URL segments with one pattern, such as sending every URL matching
/archive/(\d{4})/(.+)to a new date-based structure. Regex mode writes the pattern for Apache RewriteRule, Nginx location blocks, IIS, PHP, and JavaScript, each with its own capture syntax. - Static Hosting Migration: A move from a traditional web server to Netlify or Cloudflare Pages reuses the same rule list. Exported as CSV, it regenerates in _redirects syntax, with 410 rules and regex patterns flagged because neither host supports them.
Inputs, outputs, and what the Redirect Generator computes
What the Redirect Generator asks for and what it returns, as a plain list. Defaults, units, and ranges are the ones the form loads with.
Inputs
- Output Format · default: Apache .htaccess
- Include comments · default: on
- Treat source paths as regex patterns · default: off
- Match source paths with or without a trailing slash · default: off
- Generated redirect code
- /old-page (text input) · default: ' + escapeAttr(source || '') + '
- /new-page (text input) · default: ' + escapeAttr(target || '') + '
Controls
Generate · Reset · Copy to Clipboard · Download · Export CSV
Example
A 301 rule from /old-page to /new-page becomes Redirect permanent /old-page /new-page in .htaccess and location = /old-page { return 301 /new-page$is_args$args; } in Nginx, so a request for /old-page?utm_source=mail arrives at /new-page?utm_source=mail.