A redirect rule is a simple idea wearing three different uniforms. The idea never changes: this old path now lives at that new path, and here is the code that says how permanent the move is. But an Apache server, an Nginx server and a platform such as Cloudflare Pages each want that idea written in their own grammar, and none of them will accept another's.
This guide compares the three outputs of the free Redirect Rule Generator on Ovatly: .htaccess for Apache, Nginx rewrite lines, and the _redirects file. You enter the same from/to rows either way; what changes is the syntax the tool wraps around them, plus one genuine behavioural difference in the Nginx output.
Contents
- Quick answer
- Same rows, three outputs
- What .htaccess expects
- What Nginx expects
- The plain one: _redirects
- The one real difference: 307 and 308 in Nginx
- Worked example: one row in three formats
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
The rows are identical in every format: a from path, a to path and a status code per row, entered once in the Redirect Rule Generator. The output differs. Apache wants a short directive in a .htaccess file. Nginx wants a rewrite line with the from path anchored and escaped. Cloudflare Pages and Netlify want a _redirects file at the site root with one plain line per rule. Choose the format your server reads, because a perfect rule in the wrong file does nothing at all. One difference is more than cosmetic: in Nginx output, rows coded 307 or 308 are emitted as exact-match location blocks with a return line, because the rewrite form covers 301 and 302 only.
Same rows, three outputs
Everything starts from the same table of rows. Each row pairs a from path with a to path and carries its own status code: 301, 302, 307 or 308. The generator refuses a duplicate from-path, so each old address appears once, and it escapes any regex characters in a from path automatically, so paths match literally in whichever format you export.
Because the rows are the source of truth, switching formats costs nothing. Generate the .htaccess version for a staging server on Apache, then generate the Nginx version for production, and the two files describe the same moves. The comparison below is about grammar, not about which format produces a better redirect.
What .htaccess expects
The .htaccess file is Apache's per-directory configuration file, and its redirect directive is the most compact of the three: the word Redirect, the status code, the from path and the to path, in that order, one rule per line. There are no anchors and no punctuation beyond the paths themselves.
That compactness comes with a scope worth knowing: .htaccess is an Apache feature. Nginx does not read it, and neither do Cloudflare Pages or Netlify. A site that migrates from Apache hosting to Nginx takes its redirect intent with it, but the file itself stays behind, which is the most common reason a moved site quietly loses its redirects.
What Nginx expects
Nginx expresses the same rule as a rewrite line inside its server configuration. The from path is written as a regular expression, anchored with ^ at the start and $ at the end so it matches one exact path, and the line ends with a flag word instead of a bare number: permanent for a 301, redirect for a 302.
This is where the generator's automatic escaping earns its keep. Because the from path sits inside a regex, a dot in a real path would otherwise mean "any character". The generator escapes those characters for you, so the path you typed is the path that matches, literally. Writing these lines by hand, that escaping is the step people most often forget.
The plain one: _redirects
Cloudflare Pages and Netlify read a file named _redirects placed at the site root. Its format is the plainest of the three: the from path, the to path and the status code, separated by spaces, one rule per line. No directives, no anchors, no flags.
Plain does not mean weaker. The platform reads the file on every request and applies the matching rule, so the same row does its job here in a single short line. The tradeoff is portability in the other direction: take the site off those platforms and the _redirects file has no reader, so the rows need exporting again in the new server's format.
The one real difference: 307 and 308 in Nginx
Most of this comparison is cosmetic, but one difference is structural. The Nginx rewrite form expresses two codes with its flag words: permanent for 301 and redirect for 302. It has no flag for 307 or 308.
So when a row carries 307 or 308, the generator changes shape for Nginx output: the row becomes an exact-match location block, with a return line inside it carrying the code and the destination. The rule means the same thing and matches the same single path; Nginx simply needs it said the longer way. Neither .htaccess nor _redirects needs the detour, because both take the numeric code directly.
Worked example: one row in three formats
Take the generator's example row: from /old-soap to /soap, with the permanent code. In _redirects format the whole rule is one plain line:
/old-soap /soap 301
In .htaccess format, Apache states the same rule as a directive:
Redirect 301 /old-soap /soap
And in Nginx format, the same row comes out as:
rewrite ^/old-soap$ /soap permanent;
Read the three side by side and the pattern is clear. The paths and the intent are untouched. What changed is the wrapping: a bare line, a directive, and an anchored regex with a flag word where the number used to be. If this row carried 307 instead of 301, the first two lines would change only their number, while the Nginx version would arrive as a location block with a return line, for the reason covered above.
Limitations and honest tradeoffs
The generator validates the shape of the rules only. It cannot know whether the file you paste them into is the one your server reads, whether the destination page exists, or whether the configuration will be reloaded. Test the rules after deploying, in a browser, path by path.
Format choice is also dictated, not free. You do not pick the syntax you like best; you pick the one your hosting demands, and moving platforms means regenerating. Keeping the original rows matters for that reason: rows can be re-exported in any format, while a hand-edited configuration file has to be translated line by line.
Common mistakes
- Leaving .htaccess behind on an Nginx server. The file is simply never read. Regenerate the rules in Nginx format after any platform move.
- Hand-writing Nginx lines without escaping. An unescaped dot in a from path turns an exact path into a pattern. The generator escapes automatically; manual edits after export can undo that.
- Expecting rewrite to carry a 307. It cannot. A 307 or 308 row needs the
locationblock form in Nginx, which the generator emits for you. - Testing only the home page. A format error usually breaks every rule at once, but a wrong destination hides in individual rows. Click through the list.
- Editing one format and forgetting the others. If staging and production use different servers, regenerate both outputs from the same rows instead of patching files separately.
FAQs
What is the difference between .htaccess and Nginx redirect syntax?
They express the same rule in different grammars. An Apache .htaccess rule states the code and the two paths in a short directive, while Nginx uses a rewrite line anchored with ^ and $ and ends the permanent code with the word permanent. The Redirect Rule Generator produces both from the same rows.
Which format should I choose?
The one your server reads. Apache reads .htaccess, Nginx reads its own configuration syntax, and Cloudflare Pages and Netlify read a _redirects file at the site root. A correct rule in the wrong format is ignored completely.
What is the _redirects format for? It is the redirect file used by Cloudflare Pages and Netlify, placed at the site root. Each line is a from path, a to path and a status code, with no extra syntax around them.
Why do 307 and 308 rows look different in Nginx output?
The Nginx rewrite form expresses 301 and 302 only. For 307 and 308 the generator emits an exact-match location block with a return line instead, which is the shape Nginx needs to answer with those codes.
Is anything uploaded when I generate the rules? No. The generator runs entirely in your browser. Your paths and rules never leave your device.
Conclusion
Formats differ, intent does not. Enter your rows once in the Redirect Rule Generator, export the grammar your server speaks, and remember the single structural exception: Nginx wants 307 and 308 rules as location blocks, not rewrite lines. If those rows are part of a wider move, our guide to writing redirect rules for a domain change covers the full workflow. For more guides in this series, see our Website and Webmaster Tools guides.
References
- Apache HTTP Server documentation, on the mod_alias Redirect directive: https://httpd.apache.org/docs/current/mod/mod_alias.html
- Nginx documentation, on the ngx_http_rewrite_module and its rewrite directive: https://nginx.org/en/docs/http/ngx_http_rewrite_module.html