0

我想要做的是:

domain.com/account/manage/somekey/  ->  domain.com/account/manage/?key=somekey
domain.com/account/manage/somekey/settings/  ->  domain.com/account/manage/settings/?key=somekey

somekey 是一个包含 AF,af,0-9 长度为 24 个字符的字符串。

这是我的第一个,但我不确定如何做第二个。

location /account/manage/  {
     rewrite "^/account/manage/([A-Fa-f0-9]{24})/(.*)$" /account/manage/?key=$1;

    }
4

2 回答 2

0
location /account/manage/ {
    rewrite "^/account/manage/([A-Fa-f0-9]{24})/(settings/)?" /account/manage/$2?key=$1;
}
于 2012-07-18T18:07:31.100 回答
0

我对 nginx 没有太多经验,但试试这个版本:

location /account/manage/$  {
  rewrite ^/account/manage/([A-Fa-f0-9]+)(/[^/]*)?/?$ /account/manage$2/?key=$1;
  try_files $uri $uri/;
}
于 2012-07-18T12:14:10.033 回答