Redirect to a different url based on a query

We have a wordpress installation and need to redirect lost password link
to
another different url for this we trying to setup a redirect rule but
this
is not working. Can anyone please help us.

location / {
proxy_pass http://localhost;
}

location wp-login.php?action=lostpassword
rewrite ^(.*) http://recover.geo.com $1 permanent;
}

But login url too (wp-login.php?action=login) is redirecting to
recover.geo.com

We need to redirect only the url wp-login.php?action=lostpassword to
other
and all other url including wp-login.php?action=login need to proxypass

Can anyone please help us with the correct configuration.

Thanks
Geo

Can anyone please help me on it…

Posted at Nginx Forum:

On Thu, Sep 18, 2014 at 07:34:32PM +0530, Geo P.C. wrote:

Hi there,

We need to redirect only the url wp-login.php?action=lostpassword to other
and all other url including wp-login.php?action=login need to proxypass

Untested, but something like

location = /wp-login.php {
if ($arg_action = lostpassword) {
return 301 http://whatever$request_uri;
}
proxy_pass wherever;
}

should probably come close to what you want. You could test “$args =
action=lostpassword” if that better describes the requests that you want
to handle specially.

f

Francis D. [email protected]