Server configuration
htaccess to Nginx converter for WordPress
Moving a WordPress or WooCommerce site from Apache to Nginx? Paste your .htaccess file and this htaccess to Nginx converter writes the matching Nginx rules. It also lists every line it could not convert, with the reason and what to do instead.
- WordPress and WooCommerce
- Line-by-line report
- Private to your browser
Free, no sign-up. It runs in your browser, so nothing you paste is sent to this site.
Nothing you enter leaves your browser.
This tool runs in your browser and needs JavaScript. Turn JavaScript on and reload the page.
.htaccess to Nginx
Review your output
Your output will appear here
Complete the fields to generate valid output.
Conversion report
| Line | .htaccess | Result | What happened and what to do |
|---|
What you can do
-
Turn WordPress permalinks into try_files, including Multisite
-
Convert HTTPS, www and path redirects with their query strings
-
Keep the blocks on xmlrpc.php, wp-config.php, author scans and uploads
-
Move security headers, browser caching and compression to Nginx
-
See every line that was changed or left out, and why
How to convert .htaccess rules to Nginx
-
Paste your .htaccess file
Copy the whole .htaccess file from your site's folder and paste it in. Add your domain if you like, and change the folder if the file is not in the site root, for example /blog/ or /wp-content/uploads/.
-
Read the report
Each line is marked as converted, converted with changes, not needed in Nginx, or not converted. Read the changes and follow the advice for lines that were not converted, such as PHP settings or cache plugin rules.
-
Add the rules and test
Back up your Nginx configuration. Put the rules in your site's server block, above the PHP location, and put any http block part in the http block. Run nginx -t, reload Nginx, then test redirects, blocked files, the cart, checkout and wp-admin.
From Apache rules to Nginx rules, with nothing guessed
Nginx does not read .htaccess files, so a site moving from Apache needs its rules written again. This free converter handles what WordPress and WooCommerce sites usually have: the WordPress permalink block (single site, Multisite and subfolder installs), RewriteRule redirects and blocks, Redirect and RedirectMatch, <Files> and <FilesMatch> access rules in old and new Apache syntax, Options -Indexes, ErrorDocument, security headers, browser caching and compression.
Why some lines change
The two servers work differently, and the converter keeps to how Apache behaved:
- A RewriteRule in .htaccess matches the path without its leading slash, so the Nginx rule adds it.
- Several conditions are joined with set and a single if, the form Nginx handles safely.
- Redirects keep or drop the query string as Apache did.
- Headers are added with always, and repeated in locations that set their own, because add_header is not passed down into those locations.
- Browser cache times are set by content type, but never for pages WordPress makes, so the no-cache headers on the cart and checkout stay in place.
Know the limits
Some lines have no safe equivalent, and the report lists each one with what to do. These include PHP settings (use .user.ini or the PHP-FPM pool), environment variables, ModSecurity rules and cache plugin blocks. For cache plugins, follow the plugin's own Nginx instructions. Values that cannot be written safely in nginx.conf, such as text containing $ or quotes, are refused, not guessed. The file can be up to 3,000 lines and 100,000 characters.
Build a complete server block with the Nginx config generator, write new redirects with the redirect generator, check old and new files side by side with the configuration comparison, and test the live result with the HTTP header checker.
Frequently asked questions
Does Nginx read .htaccess files?
No. Nginx has no per-folder configuration files, so every rule has to go into the server configuration and Nginx has to be reloaded after a change. That is also why WordPress cannot write its own Nginx rules.
Where do the converted rules go?
Put them inside your site's server block, above the location ~ \.php$ block, because Nginx uses the first regular-expression location that matches. If the output has an http block part, which holds the browser-cache map, put it in the http block, for example in a file in /etc/nginx/conf.d/. Then run nginx -t before you reload.
What happens to my WordPress permalink rules?
The block between # BEGIN WordPress and # END WordPress becomes the try_files rule from the WordPress Nginx guide, with the extra rewrites a Multisite network needs. Replace your server block's existing location / with it, because Nginx refuses two.
Why are my php_value lines not converted?
Nginx does not run PHP itself; PHP-FPM does, and it does not read .htaccess. The report gives each setting as a .user.ini line and as a PHP-FPM pool line. For upload limits, also set client_max_body_size in Nginx.
What about WP Rocket, W3 Total Cache or LiteSpeed Cache rules?
Cache plugin blocks are not converted line by line. On Nginx, follow the plugin's own Nginx instructions instead. W3 Total Cache, for example, writes its Nginx rules to an nginx.conf file in the WordPress folder by default, for you to include in the server block. LiteSpeed Cache's page cache only works on a LiteSpeed server.
Is my .htaccess file uploaded?
No. The conversion runs in your browser and nothing is saved. You can copy the result or download it as a .conf file.
Related tools
-
.htaccess
New (added recently)Generate a WordPress .htaccess with security, HTTPS, WooCommerce and caching rules, plus the matching Nginx rules.
-
Generate an Nginx config for WordPress with TLS, caching, HTTP/2 and HTTP/3.
-
Generate 301 and other redirects for Nginx or Apache from a CSV list.
-
Compare two configuration files line by line, privately in your browser.