首页 > 解决方案 > AWS Elastic Beanstalk 中的 URL 重写或重定向(使用 Spring Boot 应用程序)

问题描述

我有一个托管在 AWS Elastic Beanstack 上的 Spring Boot 应用程序。

在我的应用程序属性中:

server.servlet.context-path=/PartToRemove

所以我所有的网址都是:

https://example.com/PartToRemove/path/to/the/particlar/endpoint

现在我想删除PartToRemoveto have:

https://example.com/path/to/the/particlar/endpoint

在 Spring Boot 级别很容易 - 我只需要删除行

server.servlet.context-path=/PartToRemove

从我的配置。

...我想为所有只知道旧 URL 的用户保持“向后兼容性”。所以我正在考虑设置一些从旧URLhttps://example.com/PartToRemove/path/to/the/particlar/endpoint到新https://example.com/path/to/the/particlar/endpointURL 的重写或重定向。

我对 AWS 不是很熟悉,所以我不确定在哪里执行此操作。我正在考虑 .htaccess 文件中的 mod_rewrite 之类的东西,但我不知道这是否是正确的方法。

我将应用程序部署为 zip 文件,因此.ebextensions如果有帮助,我可以使用。

关于如何实现这种重定向或重写的任何想法?

标签: amazon-web-servicesspring-bootspring-mvcamazon-elastic-beanstalk

解决方案


推荐阅读