Htaccess to Nginx Converter
Translate common .htaccess redirect, rewrite, header and error rules into Nginx directives (best effort).
Runs in your browser Your input never leaves your device.
About this tool
Paste your .htaccess and the tool translates it line by line. It understands Redirect (numeric codes plus permanent, temp and seeother), RewriteRule with its flags, Header set and ErrorDocument. Redirects become prefix matches like Apache's, so Redirect 301 /old /new becomes a rewrite that also carries over the rest of the path. R=301 or a bare R becomes permanent; R=302, 303 or 307 become redirect; other rules become last. A leading slash is added to ^ patterns, so ^blog/ becomes ^/blog/. RewriteEngine, RewriteCond and Options lines are kept as comments because they have no direct Nginx equivalent.
How to use it
- Paste the contents of your .htaccess.
- Read the Nginx output.
- Check the commented lines and port them by hand.
- Place the rules in a server or location block and run nginx -t.
Example
Apache's Redirect is a prefix match, so the rest of the path is kept.
Redirect 301 /old /new
# nginx (best-effort translation — review before use) rewrite ^/old(.*)$ /new$1 permanent;
Common problems
- RewriteCond rules are missing
- Conditions are commented out, not converted. Recreate them with if or map blocks in Nginx.
- Conditional rewrites still need manual work
- RewriteCond lines are commented out. Recreate them with if or map blocks, and always test the result with nginx -t.