我需要将 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;
重定向不起作用,我做错了什么?