nginx - nginx 将远程 URL 重定向到本地文件
问题描述
尝试做一些简单的事情(我认为),但在如何到达那里时遇到了困难。我是 nginx 的新手,这无济于事。我已经阅读了各种帖子以及我能找到的任何其他内容。
我想将 nginx 配置为将所有请求重定向到特定 URL 到 localhost 上的文件夹。例如,以下请求:
https://www.example.com/alpha/beta/gamma
https://www.example.com/alpha/beta/gamma/index.html
https://www.example.com/alpha/beta/gamma/assets/images/friend.png
https://www.example.com/alpha/beta/gamma/main.ce6329ef0ed8aa52d583.bundle.js
将提供以下文件:
/Users/flynn/Projects/new-ui/dist/index.html
/Users/flynn/Projects/new-ui/dist/index.html
/Users/flynn/Projects/new-ui/dist/assets/images/friend.png
/Users/flynn/Projects/new-ui/dist/main.ce6329ef0ed8aa52d583.bundle.js
对以 开头的 URL 的所有其他请求https://www.example.com
都不会被重定向,而只是通过。这些请求将返回响应并设置应自动发回的 cookie。
任何帮助深表感谢。
解决方案
推荐阅读
- mypy - 将 Mypy 与 Ruamel.yaml 一起使用
- python - Django 不提供基于 ImageFiled 的图像
- php - 获取最后一次注册的复杂查询无法正常工作 - 未找到列错误
- azure - Azure 数据工厂 v2 - SSIS 提升和转移
- visual-studio - 如何让 Visual Studio 显示真正的 Vue.js 错误?“命令 npm run build 以代码 1 退出。”
- ios - 在后台线程中配置 UI 然后分配回主线程
- c# - 在 Azure 环境中托管 functionapp 时从 Dictionary 读取值的问题
- javascript - 具有“colspan”和“rowspan”属性的转置表
- vba - 错误转到:获取错误消息-2147024809
- android - 如何在从服务器加载 100 多个对象并将其设置为适配器时避免 ANR;在安卓中