Developer

.htaccess to Nginx Converter

Convert Apache .htaccess directives into equivalent Nginx server block configuration. Handles RewriteRule, RewriteCond, Redirect, headers, expires, deny rules and directory index.

Last reviewed by the Radiatus Cloud team

Nginx directives appear here.

Need this built for your product?

We design, build & host secure software & APIs.

Talk to an engineer

Why the migration is harder than it looks

Apache reads a .htaccess file on every request in every directory along the path. Nginx has no per directory configuration at all: everything lives in the server block, is read once at startup, and is matched by location prefix or regular expression. That architectural difference is why a literal line by line translation frequently misbehaves. Rules that Apache applies relative to the current directory become absolute in Nginx, and a rewrite loop that Apache silently caps will make Nginx return a 500 after ten internal redirects.

What converts cleanly and what does not

Redirects, header directives, expires rules, directory index, custom error documents and access control convert almost one to one. Rewrite rules convert well when the condition is a simple file existence check or a host match, which covers the front controller pattern used by WordPress, Laravel and almost every PHP framework. What does not convert is anything relying on Apache internals: mod_rewrite maps, per directory context inheritance, RewriteBase arithmetic and %{ENV} variables set by earlier rules.

Read the output before you deploy it

This converter is a starting point that removes an hour of manual work, not a guarantee. Every line it could not translate is preserved as a comment with an explanation rather than dropped silently, so nothing disappears without you noticing. Test the result with nginx -t, then check the specific paths your rules were protecting before switching traffic.

Related tools

  • JSON Formatter — Format and beautify JSON in your browser. Pinpoints syntax errors by line and column, flags unsafe integers, and never uploads your data to a server.
  • JSON Validator — Validate JSON syntax with precise line and column errors, and check documents against a JSON Schema. Runs locally in your browser, nothing uploaded.
  • Regex Tester — Test regular expressions against sample text with live match highlighting, capture groups and flag control. Runs entirely in your browser.
  • HTML Minifier — Minify HTML by removing comments and redundant whitespace, without breaking inline elements or pre blocks. Runs entirely in your browser.

Frequently Asked Questions

Will the output work without editing?

Usually for the common patterns, but always review it. The rewrite semantics differ enough that a rule which depended on Apache per directory context needs a human decision about which location block it belongs in.

How is the WordPress front controller rule converted?

The standard RewriteCond file and directory existence pair becomes try_files $uri $uri/ /index.php?$args, which is the canonical Nginx equivalent and avoids the rewrite loop that a literal translation produces.

Does it convert mod_deny access rules?

Yes. Order, Deny from and Allow from, and the Apache 2.4 Require directives, become allow and deny lines. Note that Nginx evaluates allow and deny in order and stops at the first match, which is not identical to Apache 2.2 ordering.

What happens to directives it does not recognise?

They are emitted as comments prefixed with a note explaining why they were not converted. Nothing is silently discarded, so you can see exactly what still needs attention.

Where does the output go in my Nginx config?

Inside a server block, usually alongside your existing root and index directives. The converter emits the directives themselves rather than a full server block so you can paste them into the block you already have.

Privacy & Security

Everything runs in your browser; nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Paste your .htaccess content and press Convert to get an Nginx configuration block.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.