2

I would like to redirect:

something.com/search?keywords='value'

to

something.com/search?q='value'

Here is my Nginx config:

location ~ /search {
       if ($args ~* "keywords=(.*)") {
            rewrite ^.*$ /search?q=$arg_keywords permanent;
        }
    }

But the q parameter is empty on redirection.

What is wrong?

MrWhite
  • 11,643
  • 4
  • 25
  • 40
Ordidaad
  • 121
  • 1
  • 2

1 Answers1

1

But the q parameter is empty on redirection.

I don't see that problem. When I test the configuration as written, it creates a redirection loop because the original keywords='value' is appended to the rewritten URI.

You can prevent rewrite from including any original parameters by appending a ? to the rewritten URI.

For example:

rewrite ^ /search?q=$arg_keywords? permanent;

See this document for details.

Richard Smith
  • 11,859
  • 2
  • 18
  • 26