Nginx ↔ .htaccess Converter

Convert rewrite rules and common directives between nginx and Apache .htaccess — both ways.

About this tool

Paste nginx server/location snippets or an Apache .htaccess file and get an equivalent starting point for the other web server. Handles common redirects, rewrites, try_files/front-controller patterns, headers, deny/allow, Options -Indexes, and ErrorDocument lines.

What you get

  • Bidirectional: .htaccess → nginx server block, nginx → RewriteRule/.htaccess
  • HTTPS redirects, WordPress-style front controllers, 301/302 return/Redirect
  • Header/add_header, deny/allow, autoindex, error pages
  • Warnings for rules that need manual review
  • Live conversion as you paste config
  • One-click copy of converted snippet

How to use

Choose direction, paste your config fragment, and copy the result. Always review output before production — complex if blocks, nested locations, and module-specific syntax may need hand-editing.

Example

Convert common Apache mod_rewrite rules to nginx location blocks.

Input

RewriteRule ^blog/(.*)$ /posts/$1 [R=301,L]

Output

location /blog/ {
    rewrite ^/blog/(.*)$ /posts/$1 permanent;
}

Related searches

  • nginx htaccess converter
  • apache to nginx rewrite

FAQ

How to convert nginx config to htaccess?

Switch to nginx→.htaccess, paste server/location rewrite snippets, and copy Apache RewriteRule directives as a migration starting point.

How to convert htaccess to nginx rewrite rules?

Choose .htaccess→nginx, paste Apache rules, and copy equivalent return, rewrite, and try_files patterns for your server block.

Can I migrate Apache redirects to nginx online?

Yes—include Redirect and RewriteRule lines; common 301/302 and HTTPS patterns map to return or rewrite directives in the output.

Are nginx and htaccess conversions exact?

Common redirects, try_files, headers, and deny/allow rules translate well; complex if blocks and nested locations need manual review.

How to test htaccess rules before going live?

Paste converted rules into staging first—Apache mod_rewrite and nginx rewrite modules differ in edge cases.

By using this tool you agree to our Terms of Use and Privacy Policy. Results are provided as-is without warranty.