首页 > 解决方案 > NGINX 根据端点重定向到不同的服务器

问题描述

我需要将请求重定向http://example.com/api/v1http://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;

重定向不起作用,我做错了什么?

标签: nginxnginx-config

解决方案


推荐阅读