重写规则转换帮助 - Apache 到 Nginx

重写规则转换帮助 - Apache 到 Nginx

希望将以下 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;
}

相关内容