【问题标题】:How do i redirect a url/abc to url/abc/live-preview where abc is a variable name?如何将 url/abc 重定向到 url/abc/live-preview,其中 abc 是变量名?
【发布时间】:2021-01-14 00:35:11
【问题描述】:

我有一个 url - 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; } 但它似乎没有重定向到我想要的网址。 它重定向到https://sambit.com/admin/sites/editors/hub-page/.*/live-preview。 有人可以帮帮我吗?

【问题讨论】:

    标签: nginx redirect nginx-reverse-proxy nginx-location nginx-config


    【解决方案1】:

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

    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

    【讨论】:

      猜你喜欢
      • 2020-02-29
      • 1970-01-01
      • 2019-01-27
      • 1970-01-01
      • 2011-05-30
      • 1970-01-01
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      相关资源
      最近更新 更多