Apache .htaccess Redirect Generator
Three modes: page-by-page redirects, site hygiene (HTTPS, www, trailing slash) and a move to a new domain. Patterns are escaped for you.
Privacy and cost
This tool runs in your browser. What you type or paste is not sent to our servers and it costs nothing to use.
How it works
- Pick the mode: a list of pages and folders, HTTPS / www / trailing slash, or a domain move.
- Fill in the list or the domains. Tick "behind a proxy" if a CDN or load balancer terminates HTTPS.
- Copy the block to the top of your .htaccess, before other rewrite rules, and test a few URLs.
Example
Domain example.com with HTTPS and www on: RewriteCond %{HTTP_HOST} "^example\.com$" [NC] sends visitors to "https://www.example.com/$1" in one hop with [R=301,L], and a second rule moves the rest of the traffic to HTTPS.
What the result means
Simple redirects use mod_alias (RedirectMatch), which keeps the query string. When the host or query string must be tested the tool switches to mod_rewrite with RewriteCond, because a RewriteRule pattern never sees the query string. The www and HTTPS rules are merged so a visitor is not redirected twice.
Common problems this tool helps with
- Behind a CDN (Cloudflare in Flexible mode, for example) or a load balancer that terminates HTTPS, %{HTTPS} is off, so an HTTPS redirect loops unless the proxy option is on.
- Redirect (without Match) also redirects everything under the path: Redirect 301 /blog sends /blog/article away too. The generated patterns are anchored, so a page rule only hits that page.
- Removing the trailing slash on a real directory loops with mod_dir when the !-d condition is missing.
- Every site-wide rule you add can stack one more redirect for the same URL.
Frequently asked questions
Where do I put these rules in .htaccess?
At the top of the file, before your CMS rules (WordPress, Laravel…), otherwise the router may answer before the redirect. mod_rewrite must be enabled for blocks that contain RewriteEngine On.
Should I use www or non-www?
Both work for Google. Pick one, 301 the other to it and use it everywhere: sitemap, internal links, canonical tags.
How do I handle a domain change?
Use the move mode: the path is kept and www is included. The old domain must keep pointing at the server with a valid certificate. Keep the redirects for at least a year and declare the move in Google Search Console.
Is my data sent anywhere?
No, everything is computed in your browser.
Related tools
- Redirect Rule GeneratorOne list, six output formats. The tool checks every line, flags loops, duplicates and chains, then writes the syntax each platform expects.Free · runs in your browser
- Nginx Redirect GeneratorFor a long list the tool writes a map table (hash lookup, no regex); for a few pages, location blocks. It also writes the server blocks for HTTPS, www and domain moves.Free · runs in your browser
- Cloudflare Redirect Rule GeneratorCloudflare offers two ways to redirect: one rule per redirect (Single Redirects) or a list of exact URLs (Bulk Redirects). The tool writes both, plus a few common presets.Free · runs in your browser
- Redirect Chain CheckerPaste a URL to see every redirect it goes through before the final page, with the status code and timing of each hop.Free account · 3 live checks/day
- Canonical Tag CheckerEnter a URL or paste the HTML: the tool reads the canonicals in the HTML and the Link header, compares them with the page URL and tests the target.Free · no account needed
- URL ParserPaste a URL to see each of its components and a decoded table of its query parameters, plus the details that matter for SEO.Free · runs in your browser