Leave empty for the site’s root (or the folder named by RewriteBase). For a file in a subfolder, enter it, such as /blog/.
Nginx rules
Convert these by hand
How to use the converter
- Paste the contents of your
.htaccessfile, or load an example. If the file is in a subfolder rather than the site’s root, enter that folder. - Read the converted rules, the notes, and the list of lines that need converting by hand. The converter never guesses: if a line has no safe Nginx equivalent, it says so.
- Paste the rules inside your site’s
server { }block, runsudo nginx -t, and reload withsudo systemctl reload nginx. Then test the URLs that matter, especially redirects.
The conversion runs in your browser. Your .htaccess file is not sent to Cloudhim.
Why Nginx doesn’t read .htaccess
Apache checks every folder on the way to a file for an .htaccess file, on every request. Nginx reads its configuration once, at start-up, which is part of why it’s fast. So the rules have to move into the server configuration, and Nginx needs a reload (not a restart) whenever they change.
How the main rules translate
- Front controller (WordPress, Laravel and most PHP frameworks): the “if the file doesn’t exist, send the request to index.php” rules become one line,
try_files $uri $uri/ /index.php?$query_string;. - RewriteRule with [R=301] becomes
rewrite … permanent;, and one without R becomes an internal rewrite. Patterns get a leading slash, because Nginx matches the full path while .htaccess rules see it without the folder. - HTTPS and www redirects become an
ifon$schemeor$hostwith areturn 301. In Nginx the cleaner form is a separateserverblock per name; the Nginx Config Generator writes those for you. - Redirect and RedirectMatch become
rewriterules. Apache’sRedirectalso moves everything below the old path, which the conversion keeps. - Access rules (
Require all denied,Deny from all,<FilesMatch>) becomedeny all;in a matchinglocation. Password protection becomesauth_basic, and Nginx reads the same.htpasswdfile. - Headers, expiry and compression become
add_header,expiresandgzip. - PHP settings (
php_value) can’t live in Nginx. They’re listed for your PHP-FPM pool file instead.
What needs a human
Nginx’s if takes a single test, so rules with several RewriteCond lines, including [OR] groups and %1 back-references, are converted with one flag per condition and a final check, the usual Nginx way of combining conditions. A few things still have no safe Nginx form: RewriteMap, conditions on variables Nginx doesn’t have, the [C], [S] and [P] flags, and <Directory> or <Limit> blocks. The converter lists each of those with its line number and the reason, so nothing is silently dropped.
After switching, check a few old URLs with the Redirect Checker to confirm each one still lands where it should.