首页 > 解决方案 > 如何将 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。有人可以帮我吗?

标签: nginxredirectnginx-reverse-proxynginx-locationnginx-config

解决方案


我找到了一种方法来完成如下任务 -

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


推荐阅读