[将api / rest的Nginx URL重写为rest / v1

问题描述 投票:0回答:1

当前的API端点类似

domain.com/api/rest/[actual_module_routing_path, eg. cms/page/home]

在新系统中,它必须类似于

domain.com/rest/V1/$1

无论HTTP方法(GET,POST,PUT,DELETE)如何,它都必须工作。尝试这样的事情,我无法使其正常工作,将不胜感激一些帮助

location /api/rest {
    #Rewrite $uri=/api/rest/ back to just $uri=/rest/V1/$1
    rewrite ^/api/rest/(.*)$ /rest/V1/$1 break;
}
nginx mod-rewrite nginx-location
1个回答
-1
投票
location ~ /api/rest/(.*) 
{ 
rewrite ^(.*)$ /rest/v1/$1 redirect; 
}
© www.soinside.com 2019 - 2024. All rights reserved.