We use cookies.This website uses essential cookies to operate core features. With your consent, we also use analytics cookies to understand traffic and improve the service. For more details, see our .
If this tool helped you, you can buy us a coffee ☕
Quickly convert Apache .htaccess rewrite rules, redirects, and access control directives into Nginx config for smooth website migration.
Your configuration is converted locally in your browser and never uploaded. Supports common rewrite, redirect, error page, directory index, and response header directives.
Enter an .htaccess configuration to generate the Nginx configuration here in real time
Moving a website from Apache to Nginx can be frustrating because .htaccess rewrite rules don't work directly. One webmaster spent half a day manually converting 50 URL redirects—with our converter, you just paste them in and get the Nginx config instantly. This tool handles Apache mod_rewrite rewrite rules, RewriteCond conditions, 301/302 redirects, and common access control directives, ensuring a smooth transition.
The table below lists some of the most common .htaccess directives and their converted Nginx configurations. You can paste the .htaccess rules from the left column directly into the converter to verify the results.
| .htaccess 规则 | Nginx 配置 |
|---|---|
RewriteRule ^old$ /new [R=301,L] | rewrite ^/old$ /new permanent; |
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] | if ($host = 'www.example.com') { rewrite ^/(.*)$ http://example.com/$1 permanent; } |
RewriteCond %{REQUEST_FILENAME} !-f | try_files $uri $uri/ /index.php?$args; |
<FilesMatch "\.(htaccess|htpasswd)$"> deny from all </FilesMatch> | location ~* \.(htaccess|htpasswd)$ { deny all; } |
Open the converter page and you'll see two main areas: the input box on the left and the output box on the right. Here's how to use it:
RewriteRule ^about$ /about-us.html [R=301,L].rewrite ^/about$ /about-us.html permanent;.If the converter encounters unsupported directives, a warning message will appear at the top of the output box, indicating which lines were skipped or need manual adjustment.
Suppose you have a WordPress site with typical permalink rules in .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPressPaste it into the left input box and click "Convert". The Nginx config output on the right will be:
# WordPress permalinks
location / {
try_files $uri $uri/ /index.php?$args;
}
The converter recognizes that the core intent of these rules is “if the requested file or directory doesn't exist, pass it to index.php,” and automatically merges them into the efficient Nginx try_files directive, avoiding inefficient if blocks. You can use this config directly in your Nginx server block to achieve the same pretty permalink effect.
Scenario 1: 301 redirect old page
Input:
RewriteRule ^old-page\.html$ /new-page.html [R=301,L]Output: rewrite ^/old-page\.html$ /new-page.html permanent;Scenario 2: Domain-based conditional redirect
Input:
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]Output: if ($host = 'olddomain.com') {
rewrite ^/(.*)$ http://newdomain.com/$1 permanent;
}Scenario 3: Block access to specific files
Input:
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh)$">
Order Allow,Deny
Deny from all
</FilesMatch>Output: location ~* \.(htaccess|htpasswd|ini|log|sh)$ {
deny all;
}You can test all these examples directly in the converter—paste and see the result instantly.
Now, paste your .htaccess rules into the converter above, get your Nginx config instantly, and start your seamless migration.
Online TOML to JSON Converter
Free online TOML to JSON converter. Easily convert TOML configuration files into JSON format for seamless cross-platform deployment and API integration.
JSON to Protobuf Converter
Free online JSON to Protobuf converter. Instantly generate Protocol Buffers message definitions from JSON data.

Inverse Trigonometric Function Calculator
Accurately calculate radian values for inverse trig functions like arcsin and arccos. Supports 6 function types and custom decimal precision.

Online JWT Parser & Decoder
Parse JWT headers, payloads, and key information online. No installation required—just paste and decode.
Online TOML to JSON Converter
Free online TOML to JSON converter. Easily convert TOML configuration files into JSON format for seamless cross-platform deployment and API integration.
JSON to Protobuf Converter
Free online JSON to Protobuf converter. Instantly generate Protocol Buffers message definitions from JSON data.

Inverse Trigonometric Function Calculator
Accurately calculate radian values for inverse trig functions like arcsin and arccos. Supports 6 function types and custom decimal precision.

Online JWT Parser & Decoder
Parse JWT headers, payloads, and key information online. No installation required—just paste and decode.
Online JSON to TOML Converter
Quickly convert JSON data to TOML format. A free online tool perfect for migrating configuration files.