views:

10

answers:

1

I have been trying to do this for the last 4 hours and have searched everywhere. it would be great if you could help me with nginx rewrite rules.

I am trying to temporarily redirect hxxp://siteA/[dir] to hxxp://siteB/[dir] except for hxxp://siteA/?page=4 which I want to redirect to hxxp://siteB/?page=343

Here are the rules I have

server {
    listen 80;
    server_name siteA;
    rewrite ^/?page=4$ http://siteB/?page=343 redirect;
    rewrite  ^/(.*)$  http://siteB/$1  redirect;
}

But it seems to redirect hxxp://siteA/?page=4 to hxxp://siteB/?page=4 thus ignoring the first rule.

I have changed http to hxxp since I am not allowed to post links here.