.htaccess to Nginx Config Converter
Convert Apache .htaccess rules to Nginx configuration instantly in your browser. Free, private, and client-side — no data sent to any server.
# Nginx config will appear here...
Convert Apache .htaccess rules to Nginx configuration instantly in your browser. Free, private, and client-side — no data sent to any server.
# Nginx config will appear here...
Apache and Nginx are the two dominant web servers in use today, but they configure differently. Apache uses .htaccess files distributed throughout the document tree — each directory can override behavior for itself and its children. Nginx uses a single centralized configuration file, with no per-directory overrides. Migrating from Apache to Nginx requires translating each .htaccess directive into the equivalent Nginx location block, rewrite rule, or server directive.
Most common .htaccess use cases have direct Nginx equivalents. URL rewriting (RewriteRule) maps to Nginx's rewrite directive. Redirects (Redirect, RedirectMatch) become Nginx's return or redirect lines. Authentication (AuthType, AuthUserFile) maps to Nginx's auth_basic. CORS, custom headers, and MIME type overrides all have Nginx counterparts.
This converter parses common .htaccess directives and produces Nginx configuration syntax. Complex regex rewrites and Apache-specific module directives may need manual adjustment, but typical cases convert directly. The output is meant as a starting point — review it carefully before deploying, especially for security-sensitive directives.
Apache to Nginx migration is one of the most common operational changes in web hosting. Nginx typically uses less memory per request, handles concurrent connections more efficiently, and serves static assets faster. The migration is otherwise straightforward except for configuration translation, which is the bottleneck the converter addresses.
Reading Nginx-equivalent syntax also helps Apache administrators understand Nginx idioms. Side-by-side comparison of the two configurations clarifies how each server expresses the same intent.
Paste your .htaccess content, get Nginx config equivalents.
Apache RewriteRule with [L] flag becomes Nginx rewrite ... last;. RewriteRule with [R=301] becomes return 301 with the rewritten URL or a permanent rewrite. Conditions (RewriteCond) inside Apache's rewrite engine become if blocks in Nginx, with the standard caveat that Nginx if statements have unusual semantics inside location blocks (use them carefully).
Apache directories and FilesMatch sections map to Nginx location blocks. AuthType Basic plus AuthUserFile becomes auth_basic + auth_basic_user_file. Header set or AddHeader becomes Nginx's add_header.
Some Apache features have no clean Nginx equivalent. mod_rewrite's RewriteMap with database backend, complex environment variable manipulation, and certain Apache-specific authentication providers may require custom Nginx modules or external scripts.