nginx - 如何将 url/abc 重定向到 url/abc/live-preview,其中 abc 是变量名?
问题描述
我有一个网址 - https://sambit.com/hub/abc我想重定向到 https://sambit.com/admin/sites/editors/hub-page/abc/live-preview其中 abc 是一个变量价值 。我写了一个这样的 nginx 配置 -
location /hub { rewrite ^/hub(.*)$ https://iwillonlytestit.replica.bangthetable.in/admin/sites/editors/hub-page/$1/live-preview permanent; }
但它似乎没有重定向到我想要的 url。它重定向到https://sambit.com/admin/sites/editors/hub-page/.*/live-preview。有人可以帮我吗?
解决方案
我找到了一种方法来完成如下任务 -
rewrite ^(/hub)(.*)$ https://iwillonlytestit.replica.bangthetable.in/admin/sites/editors/hub-page$2/live-preview permanent;
这从https://iwillonlytestit.replica.bangthetable.in/hub/abc重定向 到 https://iwillonlytestit.replica.bangthetable.in/admin/sites/editors/hub-page/abc/live-preview
推荐阅读
- spring-boot - Springboot Async 方法在同一个线程中运行
- spring-boot - Spring Boot 2.0.1 + JPA+Elasticsearch 给出错误嵌套异常是 java.lang.NoClassDefFoundError: org/springframework/data/querydsl/QueryDslUtils
- javascript - 在 GitLab CI 作业上运行 TestCafe Docker 映像时出错。尝试在 BrowserStack 上执行自动化的端到端测试
- mysql - 使用一张表的多个索引优化数据库性能
- mikroc - LCD 中的左移命令无法正常工作
- android - [[15.0.1,15.0.1]] 的各种其他库正在请求库 com.google.android.gms:play-services-basement,但解析为 16.1.0
- vhdl - VHDL解析和计算一些元素
- linux - 如何使用 grep -f 仅将变量作为输入,如 echo "pattern" | grep -f - <<< $var?
- c# - 如何在 SendKeys 中发送“{}”
- c# - NSwag Wep Api 2 multipart/form-data 属性/文件上传