使用nginx隐藏部分URL

使用nginx隐藏部分URL,nginx,rewrite,ubuntu-14.04,reverse-proxy,nginx-location,Nginx,Rewrite,Ubuntu 14.04,Reverse Proxy,Nginx Location,在Ubuntu14.04 LTS中,我们如何设置一个nginx配置来满足用户和下面应用程序的两个标准 [从用户的角度] 访问 https://example.com/ https://example.com/something https://example.com/something/happens 将实际访问: https://example.com/app https://example.com/app/something https://example.com/app/somethin

在Ubuntu14.04 LTS中,我们如何设置一个nginx配置来满足用户和下面应用程序的两个标准

[从用户的角度] 访问

https://example.com/
https://example.com/something
https://example.com/something/happens
将实际访问:

https://example.com/app
https://example.com/app/something
https://example.com/app/something/happens
但我们希望浏览器url字段显示:

https://example.com/
https://example.com/something
https://example.com/something/happens
[从应用程序的角度] 应用程序需要使用这些链接,/app/作为链接的一部分:

https://example.com/app
https://example.com/app/something
https://example.com/app/something/happens
我相信指令就是你想要的:

location / {
    try_files app$uri;
}
但是,如果在应用程序中使用绝对url,这将不起作用,因为不会更改响应中的url