![重写规则转换帮助 - Apache 到 Nginx](https://linux22.com/image/584117/%E9%87%8D%E5%86%99%E8%A7%84%E5%88%99%E8%BD%AC%E6%8D%A2%E5%B8%AE%E5%8A%A9%20-%20Apache%20%E5%88%B0%20Nginx.png)
希望将以下 Apache 重写规则转换为 Nginx。我们正尝试让它在子目录上工作,但似乎无法正确使用语法。
RewriteRule ^([^//]+)/?(.{2})?/$ index.php?page=$1 [QSA,L]
RewriteRule ^([^//]+)/?(.*)?/index([0-9]*).ht(m?ml?)$ index.php?page=$1&rlVareables=$2&pg=$3 [QSA,L]
RewriteRule ^([^/][\w\-\_]+)(.+)-l?([0-9]+).ht(m|ml)$ index.php?page=$1&rlVareables=$2&listing_id=$3 [QSA,L]
RewriteRule ^((\w{2})/)?([\w-_]{3,})$ index.php?page=$3&lang=$2&account_request [QSA,L]
RewriteRule ^([^//]+)/?(^/*)?.ht(m?ml?)$ index.php?page=$1 [QSA,L]
RewriteRule ^([^//]+)/?(.*)?/?(.*)?(.ht(m?ml?)|/+)$ index.php?page=$1&rlVareables=$2 [QSA,L]
答案1
location /something {
rewrite "^/([^//]+)/?(.{2})?/$" /index.php?page=$1 break;
rewrite ^/([^//]+)/?(.*)?/index([0-9]*).ht(m?ml?)$ /index.php?page=$1&rlVareables=$2&pg=$3 break;
rewrite ^/([^/][\w\-\_]+)(.+)-l?([0-9]+).ht(m|ml)$ /index.php?page=$1&rlVareables=$2&listing_id=$3 break;
rewrite "^/((\w{2})/)?([\w-_]{3,})$" /index.php?page=$3&lang=$2&account_request break;
rewrite ^/([^//]+)/?(^/*)?.ht(m?ml?)$ /index.php?page=$1 break;
rewrite ^/([^//]+)/?(.*)?/?(.*)?(.ht(m?ml?)|/+)$ /index.php?page=$1&rlVareables=$2 break;
}