1

I searched on so many threads without any luck, maybe you can help me.

I try to redirect this link https://www.example.com/page/5/?s=gluten to https://www.example.com/gluten_specificarticle

I tried to use map solution but it does not work

map $arg_s $mypage {
    gluten /specificlink;
}

There is 2 variables in the link : '5' for page and '?s=gluten' for the search argument.

Thank you for any help

Tero Kilkanen
  • 38,887

1 Answers1

1

The $request_uri variable contains the entire URI including the query string. You will need to use an if block to test the condition.

For just one redirection, you could use:

if ($request_uri = "/page/5/?s=gluten") { 
    return 301 /gluten_specificarticle; 
}

If you have a number of redirections, use a map:

map $request_uri $redirect {
    /page/5/?s=gluten    /gluten_specificarticle; 
}
server {
    ...
    if ($redirect) {
        return 301 $redirect;
    }
    ...
}

See this document for details. See this caution on the use of if.

Richard Smith
  • 13,974