NGINX mangling rewrites when encoded URLs present

Reinis Rozitis r at roze.lv
Sat May 5 22:17:17 UTC 2018


>         rewrite  ^/(.*)$  https://example.net/$1 permanent;
>
...   
> 
> Gets re-written to
> 
> example.net/CLO/https:/apple.com
> 
> Only one forward-slash, not two before apple.com.  The original declaration was %2F%2F ?

It's probably because that way the $1 is/gets url-decoded and merge_slashes kicks in ( http://nginx.org/en/docs/http/ngx_http_core_module.html#merge_slashes ).

Try something like:

    location / {
        return       301 https://example.net$request_uri;
    }

rr



More information about the nginx mailing list