NGINX 将 URL 保持在 /location/some-path 并提供 /location/?

NGINX keep URL at /location/some-path and serve /location/?

这可能吗?

用户输入https://mywebsite.com/location/any-path

Nginx 运行 https://mywebsite.com/location/

URL 显示 https://mywebsite.com/location/any-path

这种类型的动作也有特定的名称吗?

这里可以使用nginx重定向 -

location = /location/any-path {
   return 301 /location;
  }

您想 proxy_pass 向另一个 url 发送请求,然后 proxy_redirect 更改显示给客户端的 url。

像这样:

location ~ /location/(.+) {
    resolver 8.8.8.8;
    proxy_pass https://mywebsite.com/location/index.php;
    proxy_redirect /location/ /location//;
}