Nginx to Htaccess Converter
Translate simple Nginx rewrite, add_header and error_page directives into .htaccess rules (best effort).
Runs in your browser Your input never leaves your device.
Report a problem with this tool
About this tool
Paste Nginx directives and the tool converts them line by line: rewrite becomes a RewriteRule (permanent gives R=301,L, redirect gives R=302,L, last or break give just L), add_header becomes Header set, and error_page becomes ErrorDocument. A RewriteEngine On line is added at the top. Every other line, including location, if, server and proxy blocks, is kept as a comment. Patterns are copied unchanged, including a leading slash. Only single-line directives are handled, so treat the result as a starting point, review it and test it on your server. Everything runs in your browser.
How to use it
- Paste the Nginx rules, one directive per line.
- Read the .htaccess output.
- Port the commented lines by hand.
- Save the result in your .htaccess and test it.
Example
rewrite ^/old$ /new permanent;
# Apache .htaccess (best-effort) RewriteEngine On RewriteRule ^/old$ /new [R=301,L]
Common problems
- The rewrite never matches in .htaccess
- Nginx patterns start with a slash, but patterns in a per-directory .htaccess do not. Remove the leading slash (^old$) if the rule does not match.
- Blocks such as location are commented out
- Only single-line directives are converted; rebuild block logic by hand.
- A rewrite without a flag is not converted
- The rule needs whitespace after the target; a line like rewrite ^/a /b; may be commented out. Add the flag, for example last;.