开发者

nginx rewrite question

开发者 https://www.devze.com 2022-12-25 14:26 出处:网络
I have the following rewrite 开发者_如何转开发rule rewrite ^/ab(.*)/(.*)$ /repo/ab$1/rtest/$2 break;

I have the following rewrite 开发者_如何转开发rule

rewrite ^/ab(.*)/(.*)$ /repo/ab$1/rtest/$2 break;

When the request file is /abname/index.php it gets rewritten to /abname/rtest/index.php

But if the request is of the form /abname/dir1/index.php it gets rewritten as /abname/dir1/rtest/index.php but I would want it to be rewritten as /abname/rtest/dir1/index.php

How do I write the rule ?


You need avoid the / in your first match

rewrite ^/ab([^/]*)/(.*)$ /repo/ab$1/rtest/$2 break;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号