Htaccess转Nginx

在线 htaccess 转 Nginx 工具,快速将 Apache 重写规则转换为 Nginx 配置。
注意: 此工具提供基本的转换功能,某些复杂规则可能需要手动调整。转换后请务必测试配置。
常见示例
示例 1: URL重写
# Apache .htaccess
RewriteEngine On
RewriteRule ^product/([0-9]+)$ /product.php?id=$1 [L]
# Nginx
rewrite ^product/([0-9]+)$ /product.php?id=$1 last;
示例 2: 301重定向
# Apache .htaccess
Redirect 301 /old-page.html /new-page.html
# Nginx
rewrite ^/old-page.html$ /new-page.html 301;
示例 3: 强制HTTPS
# Apache .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Nginx
if ($scheme != "https") {
    return 301 https://$host$request_uri;
}
工具介绍
在线将Apache的.htaccess重写规则转换为Nginx配置格式。支持常见的重写规则、重定向规则、访问控制等配置转换。适用于从Apache迁移到Nginx的场景。
您的足迹