NGINX根据端点重定向到不同的服务器

NGINX根据端点重定向到不同的服务器,nginx,nginx-config,Nginx,Nginx Config,我需要重定向请求,如http://example.com/api/v1至http://sub.example.com/api/v1 和http://example.com/至http://another-example.com/ 以下是我迄今为止所做的尝试: server { listen 80; server_name http://example.com/api/v1; return 200 http:/

我需要重定向请求,如
http://example.com/api/v1
http://sub.example.com/api/v1

http://example.com/
http://another-example.com/

以下是我迄今为止所做的尝试:

 server {
            listen       80;
            server_name  http://example.com/api/v1;
            return 200 http://sub.example.com/api/v1$request_uri;
它是有效的,现在我尝试添加如下内容:

        server_name  http://example.com/;
        return 200 http://another-example.com/$request_uri;
重定向不起作用,我做错了什么