rewriting $arg into request.
Reinis Rozitis
r at roze.lv
Fri Jan 31 12:37:43 UTC 2020
>
> if ($args ~ "^p=(\d+)") {
> set $page $1;
> set $args "";
> rewrite ^.*$ /p/$page last;
> break;
> }
>
> I knew there'd be a simpler way and I due to the time of night I was
> struggling.
To add to this (and the map variant by Francis) if the parameter is always 'p' you can just use $arg_p rather than regex on $args or whole $request_uri:
if ($arg_p) {
return 301 http://yoursite/p/$arg_p;
}
or
map $arg_p $hugo_url {
1234 /this_nice_title;
}
...
rr
More information about the nginx
mailing list