How do i redirect a url/abc to url/abc/live-preview where abc is a variable name?

180 views Asked by At

I have a url - https://sambit.com/hub/abc which i want to redirect to https://sambit.com/admin/sites/editors/hub-page/abc/live-preview where abc is a variable value . i wrote a nginx config like this - location /hub { rewrite ^/hub(.*)$ https://iwillonlytestit.replica.bangthetable.in/admin/sites/editors/hub-page/$1/live-preview permanent; } but it doesn't seems to redirect to the url i want . its redirecting to https://sambit.com/admin/sites/editors/hub-page/.*/live-preview. Can someone please help me out ?

1

There are 1 answers

0
sambit On BEST ANSWER

I have found a way to achieve the task like follows -

rewrite ^(/hub)(.*)$   https://iwillonlytestit.replica.bangthetable.in/admin/sites/editors/hub-page$2/live-preview permanent;

this redirects from https://iwillonlytestit.replica.bangthetable.in/hub/abc to https://iwillonlytestit.replica.bangthetable.in/admin/sites/editors/hub-page/abc/live-preview