Nginx to .htaccess Converter
Convert Nginx rewrite, return, location and header rules into an Apache .htaccess file.
Nginx to .htaccess Converter
Moving a site from an Nginx server to Apache or to shared hosting? This converter reads an Nginx server block (or just a few lines of it) and writes the matching .htaccess rules. rewrite becomes RewriteRule, return 301 becomes a redirect rule, if conditions become RewriteCond lines, try_files becomes the familiar front-controller rules, and add_header, expires, deny, error_page, index, gzip and Basic Auth are translated too. Server-level settings that do not belong in .htaccess (listen, SSL, PHP-FPM) are skipped with a note.
How to use Nginx to .htaccess Converter
- Paste your Nginx configuration, or click Try an example.
- The .htaccess rules appear as you type.
- Check the notes and any lines marked "Not converted".
- Save the result as
.htaccessin the site's folder and test your important URLs.
When it comes in handy
- Moving a site from a VPS running Nginx to cPanel or other Apache hosting.
- Reusing redirects written for Nginx on an Apache server.
- Checking how a location block is expressed in Apache.
Frequently asked questions
- Do I need mod_rewrite?
- Yes, for the redirect and rewrite rules. It is enabled on almost all Apache hosting. Headers need mod_headers and expiry rules need mod_expires, which are also usually on.
- What happens to location blocks?
- Exact and prefix locations become rules that match the same path. Locations that only protect or cache file types (such as
location ~ /\.orlocation ~* \.(jpg|css)$) become <FilesMatch> blocks. - Why is the PHP block skipped?
- In Nginx, PHP files are passed to PHP-FPM with fastcgi settings. Apache runs PHP through its own handler, so those lines are not needed in .htaccess.
- Is my configuration uploaded?
- No. The conversion runs in your browser.