Any of ?and after is a query string and is not part of the normalized URI used in locationand directives rewrite. See this document for more details .
If you want to save the query string, add it to return:
location = /old/page/ {
return 301 /new/page$is_args$args;
}
rewrite , ?:
rewrite ^/old/page/$ /new/page permanent;
/.