Htaccess Redirect Generator
Generate Apache .htaccess redirect rules: 301/302/307/308, 410 Gone, query-string matches, HTTPS, www and domain moves.
This guide is not yet available in your language and is shown in English.
Tool guide
What this tool does
Htaccess Redirect Generator turns a simple list of old and new URLs into Apache rules. Choose mod_rewrite, RedirectMatch or Redirect, add HTTPS and www canonicalisation, trailing-slash handling and whole-domain moves, and get correctly escaped patterns with explanatory comments.
Whenever URLs change (after a redesign, a CMS migration, a new domain or merged content) the old addresses keep receiving visits from bookmarks, backlinks and search results. Permanent redirects send those visitors and search engines to the new page and pass on its accumulated signals. On Apache servers the redirects usually live in an .htaccess file, whose syntax is unforgiving: an unescaped dot or a missing flag creates rules that match the wrong URLs or loop forever.
This generator reads one “old new” pair per line and writes the rules for you. It escapes regular-expression characters in paths, anchors patterns so they match exactly, handles old URLs with query strings through RewriteCond, writes [G] rules for pages that are gone for good, and can add site-wide HTTPS, www and trailing-slash rules. The rule list is processed locally in your browser.
How to use Htaccess Redirect Generator
- Paste your redirects into “Redirects (old new, one per line)”; old URLs can be paths or full URLs, and 410 marks removed pages.
- Choose the Redirect type; 301 is right for permanent moves.
- Pick a Rule style: RewriteRule for exact matches and query strings, or RedirectMatch/Redirect if mod_rewrite is unavailable.
- Set Force HTTPS, Host name and Trailing slash, and fill in the domain move fields if you are changing domains.
- Download the .htaccess output, back up your existing file, and paste the rules near its top.
- Test several old URLs with a redirect checker or curl -I to confirm one clean hop to the destination.
Tips for better results
- Redirect to the most relevant equivalent page, not to the home page; mass home-page redirects are treated like soft 404s.
- Point redirects straight to the final URL to avoid chains such as old → interim → new.
- Use 410 for content that is deliberately removed with no replacement; it signals permanence more clearly than 404.
- Keep redirects in place for at least a year, ideally indefinitely, because old links stay around for a long time.
Common use cases
- Mapping hundreds of old blog URLs to a new structure after a migration.
- Moving a site from an old domain to a new one while preserving every path.
- Forcing HTTPS and a single host name to remove duplicate versions of the site.
- Retiring discontinued product pages with 410 or redirects to their successors.
Common mistakes to avoid
- Using a prefix-matching Redirect rule that unintentionally catches other URLs starting with the same path.
- Placing rules after WordPress’s rewrite block, so they never run.
- Creating loops, for example redirecting /page to /page/ while another rule strips the slash again.
- Uploading .htaccess to an nginx server, which ignores the file; nginx needs return or rewrite directives in its config.
Frequently asked questions
What is the difference between 301 and 308?
Both are permanent. A 301 lets browsers change a POST request into a GET when following the redirect, while 308 keeps the original method and body. For normal page moves 301 is standard; 308 suits form or API endpoints.
Should I use Redirect or RewriteRule?
Redirect is the simplest but matches URL prefixes and cannot see query strings. RewriteRule (mod_rewrite) matches exact patterns and works with RewriteCond for query strings and hosts, so it is the default here.
How do I redirect a URL with a query string?
Write it as an old URL such as /shop?id=42. The generator adds a RewriteCond on %{QUERY_STRING} and uses the QSD flag so the old query is not appended to the new address.
Do redirects hurt SEO?
A correct 301 or 308 passes ranking signals to the new URL. Problems come from chains, loops, redirecting to irrelevant pages, and removing redirects too soon.
Feedback & suggestions
Help us improve Htaccess Redirect Generator. We read every message.