除了我在 AWS 中的 API 使用的路径外,我如何使用静态 html 文件响应所有 url?
How can I respond with a static html file for all urls except for the path used by my API in AWS?
我正在构建带有 angular.js/django 前端后端的 Web 应用程序,我想知道是否可以将 AWS 配置为 return 静态 html 文件对于所有 url,除了我的 api 电话。例如:
http://somewebsite.com/(non-api path)/ <- returns static.html
http://somewebsite.com/api/(path)/ <- returns the response from the api
最终目标是允许 static.html 与 EC2 运行 django api 上的 Apache 服务器完全分离,而是允许将其上传到 S3 实例连同我的其他静态文件。
如果您为网站托管配置 s3 存储桶,您应该能够定义从一个页面到另一个页面的重定向规则。参见:http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
但是,最简单的解决方案可能是在您的 django 应用程序中设置一个 catch all url 规则,然后 return 一个 HttpResponseRedirect 到您的静态页面或通过应用程序代理它。
希望这有帮助。
看完这个 我发现您可以将所有回复重定向到 return index.html 页面。
从那时起,您可以购买第二个域或创建一个子域,以将您的 api 与前端分开路由。
我正在构建带有 angular.js/django 前端后端的 Web 应用程序,我想知道是否可以将 AWS 配置为 return 静态 html 文件对于所有 url,除了我的 api 电话。例如:
http://somewebsite.com/(non-api path)/ <- returns static.html
http://somewebsite.com/api/(path)/ <- returns the response from the api
最终目标是允许 static.html 与 EC2 运行 django api 上的 Apache 服务器完全分离,而是允许将其上传到 S3 实例连同我的其他静态文件。
如果您为网站托管配置 s3 存储桶,您应该能够定义从一个页面到另一个页面的重定向规则。参见:http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html
但是,最简单的解决方案可能是在您的 django 应用程序中设置一个 catch all url 规则,然后 return 一个 HttpResponseRedirect 到您的静态页面或通过应用程序代理它。 希望这有帮助。
看完这个
从那时起,您可以购买第二个域或创建一个子域,以将您的 api 与前端分开路由。