【问题标题】:Nginx URL rewrite for api/rest to rest/v1将 api/rest 的 Nginx URL 重写为 rest/v1
【发布时间】:2020-03-29 07:52:02
【问题描述】:

当前的 API 端点是这样的

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

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

domain.com/rest/V1/$1

无论 HTTP 方法(GET、POST、PUT、DELETE)如何,它都必须工作。在 nginx 主机配置中尝试这样的事情,但我无法让它工作,非常感谢一些帮助

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】:
    location ~ /api/rest/(.*) 
    { 
    rewrite ^(.*)$ /rest/v1/$1 redirect; 
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-05
      • 2020-07-11
      • 1970-01-01
      • 2017-07-21
      • 2023-03-22
      相关资源
      最近更新 更多