.htaccess to Nginx Converter
.htaccess to Nginx Converter
Nginx does not read .htaccess files, so moving a site from Apache (most shared hosting) to Nginx means rewriting its rules by hand. This converter does the translation for you: RewriteRule and RewriteCond become rewrite, return and if blocks, Redirect and RedirectMatch become redirects, and ErrorDocument, DirectoryIndex, Options -Indexes, Header, Expires, access rules and Basic Auth get their Nginx equivalents. It recognises the common patterns, such as HTTPS and www redirects and the WordPress or Laravel front controller, and writes them the way an Nginx admin would. Anything it cannot convert stays as a comment, so nothing is lost silently.
How to use .htaccess to Nginx Converter
- Paste the contents of your .htaccess file, or click Try an example.
- The Nginx configuration appears as you type.
- Read the notes at the end and check any lines marked "Not converted".
- Paste the result inside your site's
server { }block, runnginx -tand reload Nginx.
When it comes in handy
- Moving a WordPress, Laravel or PHP site from Apache hosting to an Nginx server or VPS.
- Adding a site's old redirects to an Nginx reverse proxy.
- Learning how an Apache rule is written in Nginx.
Frequently asked questions
Why does Nginx not use .htaccess?
Is the conversion always exact?
nginx -t and try your important URLs after reloading.Where does the WordPress rule go?
location / { try_files $uri $uri/ /index.php?$args; } block, added at the end of the output. You still need the usual location ~ \.php$ block that passes PHP to PHP-FPM.Is my configuration uploaded?
Related guides
-
301 vs 302 Redirects: Which One to Use, and How to Check Them
The difference between permanent and temporary redirects, how each affects SEO, common redirect mistakes, and how to set up and test them.
-
Unix Timestamps Explained: Epoch Time for Humans
What a Unix timestamp is, why it counts from 1970, seconds vs milliseconds, time zones, the year 2038 problem, and how to convert timestamps quickly.
-
JSON vs XML vs CSV: Choosing the Right Data Format for Your Project
JSON, XML and CSV each solve a different problem. Here is how to pick the right one, plus tools to convert and validate between them.