htaccess to Cloudflare Redirects Converter
Paste the redirect rules from your Apache .htaccess file and get a Cloudflare Pages _redirects file. RewriteRule, Redirect and RedirectMatch are recognised, capture groups such as $1 become :splat, and anything that cannot be expressed in Cloudflare syntax is reported in the notes instead of being silently dropped.
.htaccess rules
_redirects
Ready — paste some input or load the sample.
100% Client-Side · Privacy First. This tool runs entirely inside your browser. Nothing you type is uploaded, logged or sent to a server — you can even use it offline.
Overview
Migrating a site from Apache to Cloudflare Pages usually means rewriting every redirect by hand, and Apache regular expressions do not translate directly. A rule such as RewriteRule ^old/(.*)$ /new/$1 [R=301,L] relies on a capture group that Cloudflare exposes as :splat, and the anchored pattern has to become a literal prefix plus a wildcard. This converter does that work mechanically: it detects the pattern shape, keeps the literal prefix, appends the wildcard, rewrites numbered capture references and maps the status flag onto the Cloudflare status code. Rules that rely on RewriteCond, on module directives such as mod_rewrite or mod_alias, or that return 403 or 410 cannot be represented in a _redirects file at all, so they are listed in the notes panel where you can plan the replacement.
How to use the htaccess to cloudflare redirects converter
- 1Open your .htaccess file and copy the redirect rules into the input panel.
- 2Read the generated _redirects lines, paying attention to the ones the notes mark as approximated.
- 3Read the notes for conditions and modules that need a Pages Function or a Worker instead.
- 4Upload the file as _redirects in the root of your Cloudflare Pages project.
- 5Test the important paths after the deploy, because a pattern that behaves differently in Cloudflare is easy to miss.
- 6Keep the original .htaccess file next to the generated one, so you can diff the two whenever a route changes later.
Cheat sheet
The syntax you will use most, and what each part does.
| Pattern | What it means |
|---|---|
RewriteRule ^old/(.*)$ /new/$1 [R=301,L] |
Becomes /old/* /new/:splat 301 — the wildcard captures the rest of the path. |
$1, $2 |
Several capture groups collapse into the single :splat placeholder, because a Cloudflare Pages _redirects file has no :splat2. A rule that cannot be expressed that way is left out and reported. |
Redirect 301 /from /to |
Becomes a plain /from /to 301 line with no wildcard needed. |
RedirectMatch ^/blog/(.*) /news/$1 |
Becomes /blog/* /news/:splat with the default 302 status. |
[R=302,L] |
The status code becomes the third field; L and other Apache flags have no counterpart. |
RewriteCond %{HTTP_HOST} ^example.com$ |
Cannot be translated — the dependent rule is emitted without the condition and flagged. |
Common mistakes
Anchors are not valid in Cloudflare patterns.
Leading ^ and trailing $ are stripped, and the literal prefix plus a trailing * does the matching instead.
RewriteCond is dropped silently.
The converter warns about every condition it finds so you can move that rule to a Worker.
A capture is followed by a file extension.
Targets like $1.png cannot be rebuilt from :splat, because Cloudflare has no way to re-append the extension.
A 403 or 410 rule disappears.
Cloudflare _redirects only issues redirects, so forbid and gone rules are reported and left out of the file.
Worked examples
A classic permalink change
RewriteRule ^blog/([0-9]{4})/(.*)$ /news/$1/$2 [R=301,L]
A /blog/* to /news/:splat redirect line with status 301, plus a comment marking the pattern as approximated.
A plain redirect
Redirect 302 /old-page /new-page
A /old-page /new-page 302 line with no wildcard, because the path has no captured part.
Frequently asked questions
Does the converter upload my .htaccess file?
No. It is parsed in your browser, which is worth knowing because an .htaccess often contains internal host names and paths that you would rather not share.
What is the difference between :splat and a wildcard?
A trailing asterisk in the source pattern marks the part of the path that is captured, and :splat is the placeholder that puts that captured text into the destination. A rule such as "/old/* /new/:splat" turns /old/a/b into /new/a/b.
Can every .htaccess rule be migrated?
No. Redirects and simple rewrites translate well, but conditional rules, mod_rewrite rewrites, aliases and proxies need a Worker or a Pages Function, and the notes tell you when that is the case.
Which status code is used when the Apache rule has none?
A plain Redirect without a code becomes a 302, which is the temporary redirect that matches the Apache default. A RewriteRule with an explicit R=301 stays a permanent redirect.
What happens to RewriteCond?
It cannot be expressed in a _redirects file, so the rule is converted without the condition and the notes warn you to review it. Moving the condition into a Worker is the reliable fix.
Why did a rule disappear from the output?
A rule that returns 403 Forbidden or 410 Gone has no equivalent in a redirect file, so it is skipped and listed in the notes instead of being dropped without a word.
Are the comment lines in my .htaccess ignored?
Yes. Every line that starts with a hash is treated as a comment and never becomes a rule, so you can paste a whole file without pre-cleaning it.
What is the difference between Redirect and RedirectMatch?
Redirect matches a literal path, while RedirectMatch treats the source as a regular expression. Both are converted, and the pattern of a RedirectMatch is approximated with a literal prefix plus a splat, which the notes flag.
Does the order of the rules matter?
Yes. Cloudflare evaluates the first matching rule and ignores the rest, so a specific rule has to come before a general one. The generated file keeps the order of your original file.
Can I migrate the whole htaccess at once?
You can paste the whole file, because the parser ignores anything that is not a redirect rule. The notes then tell you which parts need a Worker.
What happens to a rule that redirects to a relative path?
A destination that does not start with a slash is kept as it is, because Cloudflare accepts a relative target and resolves it against the incoming path. Check those lines if the site uses relative links.
How are the capture groups handled?
A capture group becomes :splat, the single placeholder a Cloudflare Pages _redirects file supports. A rule with several capture groups that cannot be expressed with one :splat is left out of the file and reported with the Cloudflare Bulk Redirect or Worker alternative, because writing a :splat2 would send visitors to a literal path.