Jan Pokorný
Jan Pokorný

Reputation: 41

Redirect a specific URL to another in 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?

Upvotes: 4

Views: 7754

Answers (1)

srain
srain

Reputation: 9082

try this configuration:

location  / {
    rewrite ^/pages/page.php3(.*)$ http://www.newserver.com/o-knihovne$1 permanent;
}

Upvotes: 8

Related Questions