0

Looking for strongly replacement GET parameter with fixed value

something like :

http://domain.com/index.php?alfa=1&beta=2&debug=true

to

http://domain.com/index.php?alfa=1&beta=2&debug=false

may be

if ($args ~ "debug=true") {
set  $args_debug false;
return 301 $uri;
}

but not work

1 Answer 1

2

You can analyse the entire query string and capture the elements before and after the token you wish to modify. So that you can construct a new URI with the other elements intact:

if ($args ~ ^(.*)\bdebug=true\b(.*)$) { 
    return 301 $uri?$1debug=false$2;
}

See this caution on the use of the if directive. However, the example given here is safe.

Sign up to request clarification or add additional context in comments.

1 Comment

condition works , Thanks. Just need construct desintaion right URL . I am lost filename (( $1, $2 , $3 is empty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.