Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect a specific URL to another in NGINX

Tags:

nginx

I need to redirect a specific url containing a parameter and an anchor to a new URL:

/pages/page.php3?page=fond_razeni_gk.htm#GKI

to

http://www.newserver.com/o-knihovne

I try:

rewrite ^/pages/page.php3\?page=fond_razeni_gk.htm$ http://www.newserver.com/o-knihovne? redirect;

but this does not work. Could you please advise me what is wrong?

like image 527
Jan Pokorný Avatar asked Feb 16 '23 07:02

Jan Pokorný


1 Answers

try this configuration:

location  / {
    rewrite ^/pages/page.php3(.*)$ http://www.newserver.com/o-knihovne$1 permanent;
}
like image 68
2 revs Avatar answered Feb 23 '23 13:02

2 revs