我有一系列指向遗留应用程序的现有链接,这些链接需要由使用哈希URL格式的Angular应用程序处理。
例如,像这样的旧网址:
example.com/downloads/anexistinguuid
需要在nginx中重定向到:
example.com/#/downloads/anexistinguuid
我尝试了以下方法:
location /downloads {
proxy_pass example.com/#/downloads/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
但这似乎不是正确的方法。
有很多关于如何从 URL 中删除哈希的示例,但此时我无法更改 Angular 应用程序的 URL 策略,并且必须保持与我已经无法更改的许多链接的兼容性。
您可能需要重定向而不是反向代理。
尝试:
location /downloads {
return 301 /#$request_uri;
}