2

How do I rewrite URIs of the form

/one/two?path=three&foo=bar

to

/one/two/three?foo=bar

using nginx?

user70549
  • 123
  • 1
  • 5

1 Answers1

4

Try this:

location ~ /one/two {
    if ($args ~ "path=([^&]+)&(.+)") {
        set $path $1;
        set $foo $2;
        rewrite ^/one/two "/one/two/$path?$foo?" permanent;
    }
}
quanta
  • 51,413
  • 19
  • 159
  • 217