.htaccess Redirect Generator
Turn a list of old and new URLs into Apache redirect rules. Set each row to exact or pattern matching, force HTTPS, canonicalize www, then copy a ready .htaccess block wrapped in <IfModule mod_rewrite.c>.
Redirects
Everything runs in your browser. Nothing is uploaded.
Redirect type
Site-wide rules
Matching
Trailing slash matches a path with or without a final slash. Keep query strings adds QSA so the original query is passed through.
.htaccess
2 rules generated
How to generate .htaccess redirects online
Add your redirects
Enter each old path and the new URL it should point to, adding a row for every redirect you need.
Set match and type
Choose 301 or 302, and mark each row as an exact path or a regular expression pattern.
Add site-wide rules
Optionally force HTTPS or canonicalize www so every request lands on your preferred address.
Copy the block
Copy the generated <IfModule mod_rewrite.c> block and paste it into the .htaccess file at your site root.
Why use this tool
Exact or pattern matching per row
Mark each rule as an exact path or a regular expression. Exact paths are escaped and anchored so characters like dots stay literal, while pattern rows pass straight through to RewriteRule with backreferences intact.
Specific rules ordered first
Broad catch-all patterns are moved after more specific paths so the first match wins and a wildcard never swallows a redirect that should have matched first.
Force HTTPS and www canonicalization
Optional site-wide rules redirect every request to HTTPS and to your chosen www or non-www hostname, each written as a clean permanent redirect.
301 or 302 with the right flags
Every rule gets the correct [R=301,L] or [R=302,L] flags, wrapped in an <IfModule mod_rewrite.c> guard so the block is safe to drop in even if rewriting is unavailable.
Escaped and ready to paste
Special characters in literal paths are escaped for you, trailing slashes can be matched optionally, and query strings can be preserved with QSA.
Runs entirely in your browser
Everything happens on your device; nothing is uploaded.
About this tool
An .htaccess redirect generator turns a plain list of old and new URLs into the Apache rewrite rules that send visitors and search engines to the right place. When you rename a page, restructure a site, or move to a new domain, old links keep working only if the server redirects them. This tool writes those rules for you, wrapped in an <IfModule mod_rewrite.c> block that you paste into the .htaccess file at your site root.
Each row can match an exact path or a regular expression. Exact paths are escaped so characters like dots and question marks are treated literally, then anchored with ^ and $ so they match one path and nothing more. Pattern rows are passed through unchanged, so you can capture groups and reuse them in the destination with $1. Rules are ordered automatically, placing specific paths ahead of broad catch-alls so a wildcard never intercepts a redirect that should have matched first. You choose 301 for permanent moves or 302 for temporary ones, and each rule gets the matching flags.
Site-wide options add a force-HTTPS rule and www or non-www canonicalization, both written as permanent redirects so one canonical address wins. Trailing-slash matching and query-string preservation are one toggle each. Build and test your patterns first with the regex tester, and tidy destination paths with slugify before you paste the block into your server config.
Frequently asked questions
- Where do I put the generated rules?
- Paste the whole <IfModule mod_rewrite.c> block into the .htaccess file in your site's root directory. If a .htaccess file already exists, add these lines near the top. The rules take effect on the next request, with no restart needed.
- What is the difference between a 301 and a 302 redirect?
- A 301 is a permanent redirect and tells search engines the old URL has moved for good, passing ranking to the new page. A 302 is temporary and keeps the original URL indexed. Use 301 for renamed or moved pages and 302 for short-lived redirects like a sale page.
- When should I use exact versus pattern matching?
- Use exact matching for a single known path like /old-page; the tool escapes and anchors it so only that path redirects. Use pattern matching when one rule should cover many URLs, for example sending every address under /blog to a new section with a regular expression and a $1 backreference.
- Why are my rules reordered?
- Rules with a broad catch-all pattern are moved after more specific ones so the first matching rule wins. Apache stops at the first rule with the [L] flag, so a wildcard placed too early would swallow paths that a later, more specific rule was meant to handle.
- Does it change my live site?
- No. This tool only generates the text of the rules. Nothing takes effect until you copy the block into your own .htaccess file and upload it to your server.
- Is my data uploaded anywhere?
- No. Everything runs in your browser; nothing is sent to a server.
Related tools
Regex Tester
Test regular expressions live against sample text, with match highlighting, capture groups, find and replace, and all six flags.
URL Parser
Paste a URL and see every part broken out, with a decoded table of its query parameters.
Slug Generator
Turn any title or phrase into a clean, URL-friendly slug for permalinks, paths, and filenames.
API Key Generator
Generate cryptographically random API keys and tokens in hex, base62, or base64url, with control over length, an optional prefix, and bulk output.
ASCII Table Reference
The full ASCII character set with decimal, hex, octal, binary, and HTML codes. Search by code, character, or name.
Atbash Cipher
Mirror the alphabet so A swaps with Z, B with Y, and so on. Atbash is its own inverse, so one field both encodes and decodes as you type.